Nginx: How to use docker log collector when nginx is running under supervisord

The official nginx docker image (Dockerfile) uses the following trick to hand off its logs to stdout and stderr so that they are captured by the docker log collector and viewable using docker logs <container-name>:

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log

I want to do the same, however I have supervisord as PID 1 in my container and it supervises the nginx process and captures stdout and stderr and puts it in it's own log file. Therefore the logs do not reach the docker log collector.

Here is the relevant block in my supervisord.conf

command=/usr/sbin/nginx -g "daemon off;"
; NOTE: We do not want to redirect stdout and stderr of a nginx process to a logfile because we want docker log collector to get them.
stdout_logfile= NOT SURE WHAT TO PUT HERE?
stderr_logfile= NOT SURE WHAT TO PUT HERE?

The supervisord docs are great ( but for stdout_logfile they don't give me the answer I need - namely, how do I configure supervisord to not intercept a processes stdout / stderr ( or to capture to a log file but also forward to normal stdout / stderr).

What I tried already:

  1. stdout_logfile=NONE - Get no logs neither stdout or to a file
  2. stdout_logfile=/var/log/supervisor/%(program_name)s.log - Get logs to a file but not stdout.
  3. Not defining stdout_logfile - Get logs to a randomly named file but not stdout.
  4. stdout_logfile=/dev/stdout - Supervisord gives a error:

    CRIT uncaptured python exception, closing channel (stdout)> (:[Errno 29] Illegal seek [/usr/lib/python2.7/dist-packages/supervisor/|runforever|233] [/usr/lib/python2.7/dist-packages/supervisor/|handle_read_event|231] [/usr/lib/python2.7/dist-packages/supervisor/|record_output|165] [/usr/lib/python2.7/dist-packages/supervisor/|_log|141] [/usr/lib/python2.7/dist-packages/supervisor/|info|273] [/usr/lib/python2.7/dist-packages/supervisor/|log|291] [/usr/lib/python2.7/dist-packages/supervisor/|emit|186] [/usr/lib/python2.7/dist-packages/supervisor/|doRollover|195])

The Illegal seek error is caused by the code in supervisord that is responsible for log file rotation. To redirect to stdout/stderr you have to disable log file rotation, as explained here: