[英]NodeJS + Forever + Docker configuration doesn't work
I have a following Dockerfile
: 我有一个以下Dockerfile
:
FROM debian:stable
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN apt-get install -y nodejs
RUN npm install forever -g
# App
ADD . /api
# Install app dependencies
RUN cd /api; npm install
EXPOSE 8080
CMD ["forever", "start", "/api/index.js", "8080"]
When I try to run docker run -p 8080:8080 my-app@1.0.0
I get the following message: 当我尝试运行docker run -p 8080:8080 my-app@1.0.0
我收到以下消息:
warn: --minUptime not set. 警告: - minUptime未设置。 Defaulting to: 1000ms 默认为:1000ms
warn: --spinSleepTime not set. 警告:--spinSleepTime未设置。 Your script will exit if it does not stay up for at least 1000ms 如果脚本不能保持至少1000毫秒,您的脚本将退出
info: Forever processing file: /api/index.js info:永远处理文件:/api/index.js
and docker container stops. 和docker容器停止。
What do I need to do to container work? 我需要对集装箱工作做些什么?
Docker exits as soon as the given command is finished. 一旦给定命令完成,Docker就会退出。 forever start SCRIPT
is starting the script as a daemon in the background, and then exiting. forever start SCRIPT
在后台启动脚本作为守护进程,然后退出。 That's why your container stops. 这就是你的容器停止的原因。
To make it work, you should start forever
in the foreground by using forever SCRIPT
. 为了使它工作,你应该forever
使用forever SCRIPT
在前台开始。 The CMD
in your Dockerfile
should be: Dockerfile
的CMD
应该是:
CMD ["forever", "/api/index.js", "8080"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.