Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting a docker container with a node.js app produces error; complains about PATH

Tags:

node.js

docker

I've been banging my head against the wall on this one for a while and need a little help.

I have a docker container built from a Dockerfile. When I try to run that container (either interactively [-i] or detached [-d]), it produces the following error:

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

This is how I'm trying to start the container (made generic for security reasons):

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

What is troublesome and confusing is that when I run the container without that command appended, I am able to cd into the directory /path/to/node/app and run:

node nodeapp.js

This works fine for me. Additionally, when I compare the contents of the "which node" command and the output of "echo $PATH", I see that everything is kosher. So, why in the heck does this refuse to acknowledge that I am its master and it should do what I say?

like image 448
Jacob Avatar asked Jun 04 '14 21:06

Jacob


2 Answers

nodejs should be work.

I don't know why, but it installed named nodejs not node in my case.

like image 186
Ephemera Avatar answered Sep 22 '22 12:09

Ephemera


In your Dockerfile, ensure your WORKDIR is set and the CMD instruction looks like one of the following:

CMD ["npm", "start"] or

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

like image 34
vhs Avatar answered Sep 19 '22 12:09

vhs