PHPfpm and Nginx not working in Docker with Superv

2019-07-11 03:40发布

问题:

I am running 2 processes inside a docker container an Nginx server and PHP-FPM with supervisord but it just keep exiting with status 1 (unexpected)

Here are the logs

2016-12-09 21:37:35,529 CRIT Supervisor running as root (no user in config file)
2016-12-09 21:37:35,596 INFO RPC interface 'supervisor' initialized
2016-12-09 21:37:35,598 INFO supervisord started with pid 1
2016-12-09 21:37:36,602 INFO spawned: 'nginx' with pid 7
2016-12-09 21:37:36,606 INFO spawned: 'php-fpm' with pid 8
2016-12-09 21:37:36,671 INFO exited: nginx (exit status 1; not expected)
2016-12-09 21:37:36,722 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 21:37:37,727 INFO spawned: 'nginx' with pid 20
2016-12-09 21:37:37,737 INFO spawned: 'php-fpm' with pid 21
2016-12-09 21:37:37,801 INFO exited: nginx (exit status 1; not expected)
2016-12-09 21:37:37,848 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 21:37:39,856 INFO spawned: 'nginx' with pid 33
2016-12-09 21:37:39,863 INFO spawned: 'php-fpm' with pid 34
2016-12-09 21:37:39,917 INFO exited: nginx (exit status 1; not expected)
2016-12-09 21:37:39,997 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 21:37:43,007 INFO spawned: 'nginx' with pid 46
2016-12-09 21:37:43,011 INFO spawned: 'php-fpm' with pid 47
2016-12-09 21:37:43,071 INFO exited: nginx (exit status 1; not expected)
2016-12-09 21:37:43,072 INFO gave up: nginx entered FATAL state, too many start retries too quickly
2016-12-09 21:37:43,130 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 21:37:43,132 INFO gave up: php-fpm entered FATAL state, too many start retries too quickly

I have added daemon off to both Nginx and PHPFPM but it still does not work Here is the Nginx.conf

user  nginx;
daemon off;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  120;

    gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

Also i have ran following command to turn daemon off inside PHP-FPM

RUN sed -i 's/;daemonize = yes/daemonize = no/g' /usr/local/php-7.0.12/etc/php-fpm.conf

Here is my supervisord.conf file

[supervisord]
nodaemon=true

[program:nginx]
command: service nginx start

[program:php-fpm]
command: service php-fpm start

[supervisorctl]
serverurl=http://localhost:8091

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[inet_http_server]
port = 8091

Can someone guide me how to run these processes inside supervisord on docker container?

Docker Container Logs

/usr/lib/python2.7/site-packages/supervisor-3.3.1-py2.7.egg/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2016-12-09 22:06:43,939 CRIT Supervisor running as root (no user in config file)
2016-12-09 22:06:43,992 INFO RPC interface 'supervisor' initialized
2016-12-09 22:06:43,994 INFO supervisord started with pid 1
2016-12-09 22:06:44,999 INFO spawned: 'nginx' with pid 8
2016-12-09 22:06:45,003 INFO spawned: 'php-fpm' with pid 9
2016-12-09 22:06:45,065 INFO exited: nginx (exit status 1; not expected)
2016-12-09 22:06:45,124 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 22:06:46,131 INFO spawned: 'nginx' with pid 21
2016-12-09 22:06:46,138 INFO spawned: 'php-fpm' with pid 22
2016-12-09 22:06:46,223 INFO exited: nginx (exit status 1; not expected)
2016-12-09 22:06:46,275 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 22:06:48,282 INFO spawned: 'nginx' with pid 34
2016-12-09 22:06:48,288 INFO spawned: 'php-fpm' with pid 35
2016-12-09 22:06:48,346 INFO exited: nginx (exit status 1; not expected)
2016-12-09 22:06:48,426 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 22:06:51,435 INFO spawned: 'nginx' with pid 47
2016-12-09 22:06:51,443 INFO spawned: 'php-fpm' with pid 48
2016-12-09 22:06:51,526 INFO exited: nginx (exit status 1; not expected)
2016-12-09 22:06:51,528 INFO gave up: nginx entered FATAL state, too many start retries too quickly
2016-12-09 22:06:51,555 INFO exited: php-fpm (exit status 1; not expected)
2016-12-09 22:06:52,558 INFO gave up: php-fpm entered FATAL state, too many start retries too quickly