使用 Supervisord 时,Nginx 经常在 docker 中退出

使用 Supervisord 时,Nginx 经常在 docker 中退出

以下是标准输出上的命令输出docker run -p 9898:80 myContainer

2019-01-03 17:23:08,600 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:10,109 INFO exited: nginx (exit status 1; not expected)
2019-01-03 17:23:11,115 INFO spawned: 'nginx' with pid 87
2019-01-03 17:23:12,176 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:13,681 INFO exited: nginx (exit status 1; not expected)
2019-01-03 17:23:14,683 INFO spawned: 'nginx' with pid 88
2019-01-03 17:23:15,710 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:17,214 INFO exited: nginx (exit status 1; not expected)
2019-01-03 17:23:18,218 INFO spawned: 'nginx' with pid 89
2019-01-03 17:23:19,281 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:20,787 INFO exited: nginx (exit status 1; not expected)
2019-01-03 17:23:21,788 INFO spawned: 'nginx' with pid 90
2019-01-03 17:23:22,840 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:24,344 INFO exited: nginx (exit status 1; not expected)
2019-01-03 17:23:25,346 INFO spawned: 'nginx' with pid 91
2019-01-03 17:23:26,361 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-01-03 17:23:27,869 INFO exited: nginx (exit status 1; not expected)

监督者配置文件(supervisord.conf):

[supervisord]
nodaemon=true

[program:nginx]
command=/usr/sbin/nginx

[program:php-fpm]
command=/usr/sbin/php-fpm -D

Dockerfile:

from centos
run yes | yum install epel-release -y
run yes | yum install nginx -y
run yes | yum install vim -y 
run yes | yum install php-fpm
run yes | yum install supervisor

copy supervisord.conf /etc/supervisord.conf
copy nginx.conf /etc/nginx/nginx.conf
copy index.html /usr/share/nginx/html
copy cal.php /usr/share/nginx/html
copy 404.html /usr/share/nginx/html

CMD ["/usr/bin/supervisord"]

我能够从主机访问 Web 服务器,并且 php 代码也由安装在其中的 php-fpm 处理。

我担心 nginx 需要频繁重启,这需要使用 Supervisord。我做错了什么?

附言:请在投票之前询问详细信息。我自己做了足够的研究后才发布。这是我最后的手段!!!

答案1

看起来 nginx 正在立即退出。这可能是由于配置文件错误、权限问题等造成的,找出原因的最佳方法是手动在容器内运行它,以确保它启动并保持运行。鉴于这是 nginx,至少一个问题是您没有在前台启动它。在其他容器中运行 nginx 的标准方式是:

nginx -g "daemon off;"

您可以在用于构建 nginx 的 Dockerfile

相关内容