Not able to see STDERR Output with docker

Viewed 29672

I'm running a php docker image (php:5.6-apache) which has apache's error and access logs redirected to STDERR and STDOUT respectively using symbolic links.

When I run the docker image in the foreground or access the docker container logs, I can see the STDOUT output. But I don't see any errors (even when I generate php errors).

Any idea why that is and how I can fix it?

I'm running docker for Mac (but I don't think this makes any difference)

Thanks

access.log -> /dev/stdout
error.log -> /dev/stderr
other_vhosts_access.log -> /dev/stdout

Edit / Solved: As @BMitch mentions and proves below, the STDERR redirection works fine. The problem was with PHP configuration. If I logged an error with error_log(), it would get output to the log. But if I had a php error, like calling an undefined function, the error would never appear in the log. This seems a little inconsistent. In any case, ...

I had to create a php.ini file in /usr/local/etc/php/ and add these two parameters:

log_errors = On
error_log = /var/log/apache2/error.log

and then restart the docker container. This caused all PHP errors to be logged and output to STDERR. See @German's answer for an example.

3 Answers
Related