我的Dockerfile
包含pm2 start
命令,如下所示:
FROM node:10
WORKDIR /usr/src/app
COPY . .
# ...
EXPOSE 8080
CMD [ "pm2", "start", "npm", "--", "start" ]
但是,在成功启动pm2日志后,容器立即退出:
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /usr/local/bin/npm in fork_mode (1 instance)
[PM2] Done.
如何使容器保持与pm2一起运行?
答案 0 :(得分:1)
问题是pm2 start
将pm2作为守护程序运行,Docker并不知道。
您需要使用pm2-runtime
使其在前台运行:
CMD [ "pm2-runtime", "start", "npm", "--", "start" ]