Home » Php » docker – From where is my php.ini being loaded?

docker – From where is my php.ini being loaded?

Posted by: admin July 12, 2020 Leave a comment


I am running this Docker instance of a linux debian:jessie with php 5.6.

This is part of my phpinfo :

enter image description here

As we can see the php.ini should be located at


And this is what I have inside /usr/local/etc/

enter image description here

But there is no php.ini inside it.

I the other hand, I have the php.ini inside

enter image description here

So, from where exactly is my php.ini being loaded?

We dont even have a php process running but the php seems to be ok – being displayed phpinfo in the screen.

enter image description here

How to&Answers:

Let try it as an answer:

It does not exist at all, which means php will run the default options.

Look at your docker file, it starts from a “clean” OS, installs Apache and PHP in it. But it never copies the php.ini file from the PHP installation into /usr/local/etc/php. Actually in lines 31 and 32 it creates the conf.d directory but that is it.

So I would suggest, at the end of your docker file, add code to copy php.ini-production to /usr/local/etc/php.ini, and edits as required. Or use default options.


The default php.ini file that the docker php images look for is:


You can see this in the output from the phpinfo function (just run “php -a” in the container and then “phpinfo();” at the prompt):

Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini

You can always link this file in as a volume to get a custom one when running the container with a -v option like:

docker run -v /local/path/to/php.ini:/usr/local/etc/php/php.ini [OPTIONS] IMAGE [COMMAND] [ARG...]

I typically prefer to use the default ini file that comes with it, with just a few modified options as I need them. If you want your container to do this during build, you can do something like the following in the Dockerfile:

    RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
        sed -i -e "s/^ *memory_limit.*/memory_limit = 4G/g" /usr/local/etc/php/php.ini

The RUN commands above will copy the default production ini file, and then will modify the memory_limit and set it to 4G in the ini file.

I prefer this method because it allows custom configurations to be used so the container always works with defaults when it’s pulled, but you still have the option to override the ini file in the container by passing a volume in.


A little late to the party but since question is still relevant today, let me add a short answer:

Official php:7 images get their settings from /usr/local/etc/php folder.

# First log into the running container
$ docker exec -it «container_name» /bin/bash

# List folder content
$ ls /usr/local/etc/php

# Which outputs following line
conf.d  php.ini-development  php.ini-production

If needed, modifying settings via conf.d folder seems better alternative, since xdebug uses it. For example, you can change upload size by adding uploads.ini to conf.d folder with the following content:

file_uploads = On
memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600

Complete list of ini directives can be found at https://www.php.net/manual/en/ini.core.php


Short answer is you don’t need one. If you’re missing or want to add extensions, you can do so in your Dockerfile by doing docker-php-ext-install or docker-php-ext-enable.

Most of the common ones, you can simply do enable, such as mbstring for example, but for some less common ones, you might have to run pecl first or something to get the package. Take a look at this Docker documentation page for more information on php extensions