使用 docker 运行 node 需要使用 pm2吗?
世界只因有你
世界只因有你 2017-04-26 09:01:09
0
4
1706

使用 docer 应该尽量遵循 one process per container
但是 node 挂了怎么办?
我尝试在容器内使用 Pm2,但是容器一起来就结束了, docker 容器至少需要保证有一个进程,如果没有就会退出.可是我使用pm2为什么不行呢?
如果不能使用 pm2, docker run restart always 可以解决吗?

世界只因有你
世界只因有你

reply all(4)
刘奇

When pm2 is used in docker, you need to change the pm2 command to the pm2-docker command so that it can run in the foreground. And I personally feel that there is no need to use pm2 in docker. If the node process hangs, the corresponding container will also stop running, so when starting the docker container, add the restart=always parameter to automatically restart it

大家讲道理

You can refer to: pm2 official website’s docker integration documentation

曾经蜡笔没有小新

You need to ensure that pm2 is running in the foreground, which means that the process started in CMD or ENTRYPOINT in the dockerfile cannot run in daemon mode

某草草

You can specify the number of CPU cores to use when running a container. If you only allocate one core, there is no need to start multiple Node.js processes, because the basic scheduling unit of the CPU is a thread. Only one core means that you can run one Node.js process.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template