Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error starting node with forever in docker container

i have a problem when start node with forever in docker container, if i launch manually works, instead the same command in Dockerfile, when build and start the container, exited. The command works in bash:

docker run -it container_name bash forever start -c 'node --harmony' /my/path/app.js

I tried to put command in Dockerfile but the container don't start

CMD forever start -c 'node --harmony' /my/path/app.js
like image 513
hellb0y77 Avatar asked Oct 07 '14 13:10

hellb0y77


3 Answers

Google Group discussion

Forever start script.js runs in the background. To run forever in the foreground, try forever script.js.

This starts forever in the foreground, which is what Docker needs. Remember a container is "alive" only as long as the process defined in CMD is up and running. Since forever starts as a daemon, the command itself exits and docker will exit also.

CMD forever -c 'node --harmony' /my/path/app.js
like image 106
Eric Francis Avatar answered Oct 13 '22 15:10

Eric Francis


Try using the array syntax:

CMD ["forever", "start", "-c", "node --harmony", "/my/path/app.js"]
like image 20
Peter Lyons Avatar answered Oct 13 '22 15:10

Peter Lyons


I'm now trying to use forever in docker. This works:

CMD ["forever", "src/app.js"]
like image 35
Bruce Lee Avatar answered Oct 13 '22 16:10

Bruce Lee