phpdocker

Access php error logs in Docker


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...


Solution

  • 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