在docker容器中永远启动节点时出错

hel*_*y77 15 node.js forever docker

我有一个问题,当启动节点永远在docker容器中,如果我手动启动工作,而不是相同的命令在Dockerfile中,当构建并启动容器时,退出.该命令在bash中有效:

docker run -it container_name bash forever start -c 'node --harmony' /my/path/app.js
Run Code Online (Sandbox Code Playgroud)

我试图将命令放在Dockerfile中,但容器没有启动

CMD forever start -c 'node --harmony' /my/path/app.js
Run Code Online (Sandbox Code Playgroud)

Eri*_*cis 30

Google小组讨论

Forever start script.js在后台运行.要forever在前台运行,请尝试forever script.js.

这开始于前景,这是Docker所需要的.只要CMD中定义的进程启动并运行,请记住容器是"活着的".由于永远作为守护进程启动,命令本身退出并且docker也将退出.

CMD forever -c 'node --harmony' /my/path/app.js
Run Code Online (Sandbox Code Playgroud)

  • 请记住,目前**[一个公开的问题](https://github.com/foreverjs/forever/issues/729)**会阻止前台运行永远退出. (4认同)