Running docker container with node.js application causes an error; complaining about PATH

For a moment I hit my head against the wall, and I need a little help.

I have a docker container built from a Docker file. When I try to start this container (either interactively [-i] or disconnected [-d]), it causes the following error:

2014/06/04 21:17:40 exec: "node": the executable was not found in $ PATH

This is how I try to start the container (created for security reasons):

sudo docker run -i -t -p port: port contain name: includeerversion node / path / to / node / app / nodeapp.js

What is troubling and confusing is that when I start the container without adding this command, I can write cd to the directory / path / in / node / app and run:

node nodeapp.js

This works great for me. Also, when I compare the contents of the "node" command and the output of "echo $ PATH", I see that everything is kosher. So why the hell does this refuse to admit that I am his master and that he should do what I say?

+7
docker
source share
3 answers

nodejs should work.

I do not know why, but in my case, he installed with the name nodejs not node .

+4
source share

In your Docker file, make sure your WORKDIR installed and the CMD command looks like one of the following:

CMD ["npm", "start"] or

CMD ["node", "nodeapp.js"]

+1
source share

Try running it like this:

 sudo docker run -i -t -p port:port containername:containerversion /path/to/node/bin/node /path/to/node/app/nodeapp.js 

It should be possible to add it to your path, but I don't know how to do it. But even if you could, it still makes sense to use the full path as described above, because you would not accidentally execute another node in this way.

0
source share

All Articles