栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nginx docker CMD命令 容器启动不了

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx docker CMD命令 容器启动不了

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:80



Welcome 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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/289917.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号