0

I am building my app using official php docker image.

Case 1: When I run supervisord with root user and subprocess php-fpm with www-data user. I always get this error log:

FPM initialization failed
failed to open error_log (/proc/self/fd/2): Permission denied (13)

My supervisor config:

[unix_http_server]
file=/run/supervisord.sock  ; the path to the socket file

[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; supervisord pidfile; default supervisord.pid

nodaemon=true ; start in foreground if true; default false

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

[supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL for a unix socket

[include]
files = /etc/supervisor.d/*.conf

My subprocess php-fpm config:

[program:php-fpm]
process_name=%(program_name)s
command=php-fpm
user=www-data
autostart=true
autorestart=true
redirect_stderr=false
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

Note that if I change user of subprocess php-fpm from www-data to root, it worked perfectly

Case 2: When I run supervisord with www-data user (with a little change in config file in order to run it) and subprocess php-fpm also with www-data user, everything works fine.

My supervisor config:

[unix_http_server]
file=/app/supervisord.sock  ; the path to the socket file

[supervisord]
logfile=/app/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/app/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=true ; start in foreground if true; default false
user=www-data                     ; setuid to this UNIX account at startup; recommended if root


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

[supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL for a unix socket

[include]
files = /etc/supervisor.d/*.conf

My subprocess php-fpm config:

[program:php-fpm]
process_name=%(program_name)s
command=php-fpm
user=www-data
autostart=true
autorestart=true
redirect_stderr=false
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

What is the difference between these 2 cases? Thank you!

6
  • .. do you even need supervisor in your Docker container? What benefit does it add? Commented Mar 24, 2024 at 17:44
  • @muru Yeah I use supervisor to run 2 another subprocesses of my app and crontab. Commented Mar 25, 2024 at 1:19
  • ... But why? Just run them in two new containers with shared volumes and let Docker do the management Commented Mar 25, 2024 at 1:55
  • @muru sorry for the missing information. For example I want to run and manage 8 subprocesses queue worker of Laravel (using them same syntax command). I think create 8 containers for each subprocess maybe is not a good idea? laravel.com/docs/11.x/queues#supervisor-configuration Commented Mar 25, 2024 at 6:45
  • Why not? Anybody who uses container management tech like k8s or ECS is basically running N containers for N worker processes. Even Docker Compose has had scaling (now called replicas) since forever. Why force this supervisor stuff into your container workload when your container system is basically a replacement for supervisor and the like? Commented Mar 25, 2024 at 6:56

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.