Two things are actually required. First we need to redirect access.log to /dev/stdout and error.log to /dev/stderr. An easy way to do it in docker is by aliasing the nginx logs to stdout and stderr. We can do it by adding this to our Dockerfile :
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
However this is not sufficient, because supervisor capture output of processes it manages. Nginx logs now ends up in /var/logs/supervisor/nginx-*.log.
We need to tell supervisor to redirect logs it captures to /dev/stdout.
[program: nginx]
command=nginx -g ‘daemon off;’
autostart=true
autorestart=true
stopsignal=QUIT
exitcodes=0
numprocs=1
startsecs=10
startretries=3
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
We can now run docker-compose up and watch nginx output