Make a Docker application write to stdout
An amazing recipe is given in the nginx Dockerfile:
# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
Simply, the app can continue writing to it as a file, but as a result the lines will go to stdout
& stderr
!
For a background process in a docker container, e.g. connecting with exec to /bin/bash I was able to use.
echo "test log1" >> /proc/1/fd/1
This sends the output to the stdout of pid 1, which is the one docker pickups up.