在docker容器中永远停止启动节点 [英] Error starting node with forever in docker container

查看:455
本文介绍了在docker容器中永远停止启动节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我试图在Dockerfile中放置命令,但容器不开始

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

CMD forever start -c 'node --harmony' /my/path/app.js


推荐答案

Google群组讨论

永远启动script.js 在后台运行。要在前台运行 forever ,请尝试 forever script.js

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


这是始终在前台,这是Docker需要的。只要在CMD中定义的进程启动并运行,记住一个容器是活着的。由于它永远是一个守护进程,所以命令本身退出并且docker也将退出。

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

这篇关于在docker容器中永远停止启动节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆