After a lot of researching, appearantly when you run Apache as main process for Docker, then docker logs follows /proc/1/fd/1 instead of /proc/self/fd/1.
Problem:
I am using apache2 as web server and unfortunately apache's www-data user cannot write to /proc/1/fd/1
Code for testing:
$handle = fopen('/proc/1/fd/1', 'a');
fwrite($handle, 'abc');
fclose($handle);
This gives me output of: fopen(/proc/1/fd/1): Failed to open stream: Permission denied
Goal:
Having possibility to write to output that Docker logs can follow while having possibility to write persistent volume as well (not exactly part of this topic, but maybe useful).
Extra info:
- even though logs go to persistent volume as well, tailing these files is unpreferred option.
- research said that editing permissions of /proc/xxx/xxx folders is unwise and also quick proof of concept said that is easily not doable.
- related to: PHP in Docker - fopen() or file_put_contents() cannot write to /proc/1/fd/2 for stdout writing