How to redirect logs of non pid 1 process to dockerlogs?
There are 2 processes inside the docker container:
- pid 1 process
- non pid 1 process which writes to log file at path
Following docker docs
The official nginx image creates a symbolic link from /dev/stdout to /var/log/nginx/access.log, and creates another symbolic link from /dev/stderr to /var/log/nginx/error.log, overwriting the log files and causing logs to be sent to the relevant special device instead.
Only pid 1 process logs are redirected to dockerlogs
ln -sf /dev/stdout _path_ in Dockerfile
2 Running the updated image as container.
docker logs -f _containerid_ shows only logs of pid 1 process
There’s another official docker source
Docker supports different logging drivers used to store and/or stream container stdout and stderr logs of the main container process (pid 1)
So it maybe the reason for not seeing the logs of non pid 1 process.
Though, still don’t understand why the created symbolic link by ln -sf /dev/stdout /var/log/mysql/error.log hasn’t worked.