Start a docker container with below Dockerfile. Since it has CMD [“nginx”]. The docker container exists after nginx command is finished. It couldn’t be connected even with –detach mode.
In order to keep the docker container running, needs the CMD run in foreground. Let it keep running. So it needs a “daemon off” in nginx.conf file.
FROM ubuntu:14.04 RUN apt-get update RUN apt-get install -y nginx #RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf CMD ["nginx"] EXPOSE 80 EXPOSE 443