06 Mar

WordPress Docker containers and display of PHP warnings

I use a Docker container to host a WordPress blog and I recently upgraded the Docker image to one based on an image which used PHP 7.2. I had previously been using one based on Apache with PHP 5.6.

I immediately noticed warnings being displayed at the top of the blog

The warnings where from PHP letting a developer know that their code had a non fatal error. The cause of the error is a subject for another blog post. I just wanted to turn off the display of these warning messages.

To do this you can set the display_errors configuration variable to Off in php.ini

Create a file called hide_errors.ini with the following content

display_errors = Off

I then proceeded to recreate my WordPress docker container with the same volume as the current container used, as well as mounting hide_errors.ini to /usr/local/etc/php/conf.d/hide_errors.ini inside the container.

After this the warnings were no longer displayed.

Leave a Reply

Your email address will not be published. Required fields are marked *