Error starting node with forever in docker container

99封情书 提交于 2019-11-29 06:24:21

问题


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

回答1:


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



回答2:


Try using the array syntax:

CMD ["forever", "start", "-c", "node --harmony", "/my/path/app.js"]



回答3:


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

CMD ["forever", "src/app.js"]



回答4:


Put in your Dockerfile :

CMD forever app.js


来源:https://stackoverflow.com/questions/26237044/error-starting-node-with-forever-in-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!