'Nginx frequently exits within docker while using supervisord
I build an image that contains multiple tools(such as mysql, nginx, java, etc) with the following binary and start it through supervisord. It is referenced from the project
However, nginx failed to start during startup
However, an error was reported when starting nginx.
The nginx build command follows
ARG OS_VER=7
FROM centos:$OS_VER
#nginx版本
ARG NGINX_VER=1.20.2
...
...
#安装nginx
RUN cd /usr/src \
&& curl -o nginx.tar.gz http://nginx.org/download/nginx-${NGINX_VER}.tar.gz -L \
&& mkdir nginx && tar -xzvf nginx.tar.gz -C ./nginx --strip-components 1 \
&& cd nginx \
&& ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock \
--user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module \
--with-http_gzip_static_module --http-client-body-temp-path=/tmp/nginx/client/ \
--http-proxy-temp-path=/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/tmp/nginx/fcgi/ \
--with-pcre --with-http_dav_module \
&& make && make install \
&& useradd nginx \
&& mkdir -p -m 777 /tmp/nginx \
&& echo "#!/bin/sh" > /etc/init.d/nginx \
&& echo "#description: Nginx web server." >> /etc/init.d/nginx \
&& echo -e "case \$1 in \n\
restart): \n\
/usr/local/nginx/sbin/nginx -s reload \n\
;; \n\
stop): \n\
/usr/local/nginx/sbin/nginx -s stop \n\
;; \n\
*): \n\
/usr/local/nginx/sbin/nginx \n\
;; \n\
esac \n" >> /etc/init.d/nginx \
&& chmod +x /etc/init.d/nginx \
#&& sed -i "3a daemon off;" /etc/nginx/nginx.conf \
#&& sed -i "s/index index.html index.htm;/index index.php index.html index.htm;/" /etc/nginx/nginx.conf \
#&& sed -i "s/# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000/location ~ \.php\$ { \nfastcgi_pass 127.0.0.1:9000;\nfastcgi_index index.php;\nfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\ninclude fastcgi_params;\n }/" /etc/nginx/nginx.conf \
&& echo "<?php phpinfo()?>" > /usr/local/nginx/html/index.php \
# && rm -rf /etc/nginx && cp -rf /usr/src/etc/nginx /etc/nginx \
&& mkdir -m 777 -p /var/log/nginx \
&& rm -rf /usr/src/nginx.tar.gz && rm -rf /usr/src/nginx
RUN echo [supervisord] > /etc/supervisord.conf \
&& echo nodaemon=true >> /etc/supervisord.conf \
&& echo user=root >> /etc/supervisord.conf \
\
&& echo [program:nginx] >> /etc/supervisord.conf \
&& echo command=/usr/local/nginx/sbin/nginx >> /etc/supervisord.conf \
\
&& echo [program:crond] >> /etc/supervisord.conf \
&& echo command=/usr/sbin/crond -n >> /etc/supervisord.conf \
CMD ["/usr/bin/supervisord"]
The error at startup is as follows
2022-04-19 10:40:44,652 INFO exited: nginx (exit status 1; not expected)
2022-04-19 10:40:45,656 INFO spawned: 'nginx' with pid 117
2022-04-19 10:40:45,658 INFO spawned: 'crond' with pid 118
2022-04-19 10:40:46,094 INFO exited: crond (exit status 254; not expected)
2022-04-19 10:40:46,173 INFO gave up: crond entered FATAL state, too many start retries too quickly
2022-04-19 10:40:46,673 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-04-19 10:40:48,175 INFO exited: nginx (exit status 1; not expected)
2022-04-19 10:40:49,178 INFO spawned: 'nginx' with pid 131
2022-04-19 10:40:50,194 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-04-19 10:40:51,695 INFO exited: nginx (exit status 1; not expected)
2022-04-19 10:40:52,699 INFO spawned: 'nginx' with pid 132
2022-04-19 10:40:53,720 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-04-19 10:40:55,221 INFO exited: nginx (exit status 1; not expected)
2022-04-19 10:40:56,224 INFO spawned: 'nginx' with pid 133
2022-04-19 10:40:57,241 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
crond stops restarting, nginx keeps exiting
What are the reasons for the above two errors and how to solve them?
I really appreciate any help with this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
