I have a docker container that runs several services inside it. I want each service to have it's output sent to the console. The is a development container so I want to see all output as I work.
I tried this file:
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
priority=900
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
username=www-data
autorestart=true
autostart=true
[program:php-fpm]
command=/usr/sbin/php-fpm7.4 -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=5
[program:memcached]
command=/usr/bin/memcached -u root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
priority=200
But it only outputs the supervisord messages and not the messages from the services. I saw another thread where ther sent log messages to /dev/fd/1
so I tried that also and it didn't work.
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
My base image is ubuntu 20.04.
Why cant I get the services log messages into console?
Best Answer
First, don't use supervisord and docker, pick one or the other, if you are using docker, use docker compose and a split out each service using docker to control the process, but if you're going to do this anyway... I started supervisor with
supervisord -n
and updated my nginx config to send logs to /dev/stderr and /dev/stdout and everything is working as expected. the startup commands for nginx are sent to /dev/stdout by supervisord and the nginx logs are send to the place configured by nginx, only error_log is configurable for nginx startup parameters, see specific links below.sshd logging
nginx logging
php-fpm logging
memcached logging (verbose)