I have a following 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:
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info: Forever processing file: /api/index.js
and docker container stops.
What do I need to do to container work?
Docker exits as soon as the given command is finished. forever start SCRIPT
is starting the script as a daemon in the background, and then exiting. That's why your container stops.
To make it work, you should start forever
in the foreground by using forever SCRIPT
. The CMD
in your Dockerfile
should be:
CMD ["forever", "/api/index.js", "8080"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.