NodeJS + Forever + Docker configuration doesn't work
I have a following
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 email@example.com 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?
One Solution collect form web for “NodeJS + Forever + Docker configuration doesn't 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"]