Docker, Supervisord and logging - how to consolidate logs in docker logs? Docker, Supervisord and logging - how to consolidate logs in docker logs? python python

Docker, Supervisord and logging - how to consolidate logs in docker logs?


I accomplished this using .

Install supervisor-stdout in your Docker image:

RUN apt-get install -y python-pip && pip install supervisor-stdout

Supervisord Configuration

Edit your supervisord.conf look like so:

[program:myprogram]command=/what/ever/commandstdout_events_enabled=truestderr_events_enabled=true[eventlistener:stdout] command = supervisor_stdout buffer_size = 100 events = PROCESS_LOG result_handler = supervisor_stdout:event_handler


Docker container is like a kleenex, you use it then you drop it. To be "alive", Docker needs something running in foreground (whereas daemons run in background), that's why you are using Supervisord.

So you need to "redirect/add/merge" process output (access and error) to Supervisord output you see when running your container.

As Drew said, everyone is using https://github.com/coderanger/supervisor-stdout to achieve it (to me this should be added to supervisord project!). Something Drew forgot to say, you may need to add

stdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0

To the supervisord program configuration block.

Something very usefull also, imagine your process is logging in a log file instead of stdout, you can ask supervisord to watch it:

[program:php-fpm-log]command=tail -f /var/log/php5-fpm.logstdout_events_enabled=truestderr_events_enabled=true

This will redirect php5-fpm.log content to stdout then to supervisord stdout via supervisord-stdout.


supervisor-stdout requires to install python-pip, which downloads ~150mb, for a container I think is a lot just for install another tool.

Redirecting logfile to /dev/stdout works for me:

stdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0

http://veithen.github.io/2015/01/08/supervisord-redirecting-stdout.html