nginx dockerfile 配置nginx启动
CMD ["nginx"] ######### 容器启动不了 ######## [hadoop@hadoop03 fastdfs-docker]$ sudo docker ps -a ConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d0b4d37f1121 9d24dd437383 "/usr/local/bin/run.…" 5 seconds ago Exited (0) 3 seconds ago confident_moser [hadoop@hadoop03 fastdfs-docker]$
If you add a custom CMD in the Dockerfile, be sure to include -g daemon off; in the CMD in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!
dockerfile 文件添加
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
[hadoop@hadoop03 fastdfs-docker]$ sudo docker exec -it f0 bash [root@f049b8bd8e89 /]# ps aux | grep nginx root 1 0.1 0.0 28104 1724 ? Ss 07:07 0:00 nginx: master process nginx nobody 7 0.0 0.0 28680 1780 ? S 07:07 0:00 nginx: worker process root 28 0.0 0.0 9196 684 pts/0 S+ 07:08 0:00 grep --color=auto nginx [root@f049b8bd8e89 /]# curl localhost:80Welcome to nginx! Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.Thank you for using nginx.
[root@f049b8bd8e89 /]#
参考:https://www.cnblogs.com/luguojun/p/14294659.html



