How can I access the php error logs for my container?
For some reason I'm really struggling to find out how to do this after a long time of searching various articles.
I'm using a simple php7 apache container which looks like: FROM php:7-apache
RUN apt-get update -y && apt-get install -y \
libpng12-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
curl \
libcurl4-openssl-dev \
libxpm-dev \
libvpx-dev \
&& docker-php-ext-configure gd \
--with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \
--with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \
--with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \
--with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \
&& docker-php-ext-install \
pdo \
pdo_mysql \
gd \
curl \
&& a2enmod rewrite \
&& service apache2 restart
Ideally I just need to view the contents of the error log or get a new custom log set locally on my machine so I easily see potential issues with my site build.
Any pointers appreciated. I found the docker documentation very confusing on the topic of logs...
The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.
The location of the error log file itself can be set manually in the php. ini file. On a Windows server, in IIS, it may be something like "'error_log = C:\log_files\php_errors. log'" in Linux it may be a value of "'/var/log/php_errors.
You can also find the logs for the internal components included in Docker Desktop at $HOME/. docker/desktop/log/ .
It exists the following docker command:
docker logs -f --details containerName
that will show you the mysql and php errors log files
for more check the documentation: docker logs
By default the container doesn't seem to log PHP errors to STDOUT or STDERR. I found that when using the php.ini-development
config file (see 'Configuration' in this article) it logs a lot more useful information.
To view the logs for a container, the most basic way is to do docker ps
, find the container hash, and then do docker logs container_hash
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With