Reputation: 12557
I created a docker image based on nginx and included the config in the image it self.
ThenI start the container (docker run -p 2000:80 nginx_be:0.1
).
When I don't check for running containers with docker ps
there are none.
What am I missing?
My Dockerfile
FROM nginx
ADD /conf/nginx.conf /etc/nginx/nginx.conf:ro
WORKDIR /etc/nginx
EXPOSE 80
CMD ["nginx", "-c", "/etc/nginx/nginx.conf"]
Upvotes: 3
Views: 1542
Reputation: 1329592
The latest nginx Dockerfile does end with:
CMD ["nginx", "-g", "daemon off;"]
You should do the same in order to avoid nginx launching as a daemon (background), which would make the container stop immediately (because of the lack of a foreground process).
See also "How to Keep Docker Container Running After Starting Services?".
You can also see this docker run command which override your Dockerfile CMD
:
docker run -t -d --name my-nginx nginx /usr/sbin/nginx -g "daemon off;"
Upvotes: 4