Docker Community Forums

Share and learn in the Docker community.

How to get access to php.ini file

Final status update

The line docker image build -t gforghetti/wordpress:latest . is incorrect - (the word image should be removed), so the correct version is:

docker build -t gforghetti/wordpress:latest .

(I used a different tag, of course).

When I started this new app via docker compose, I found this situation:

Once I added all missing plugins, I was also able to add the plugin that previously would not load (because of the 2M limit).

In summary, your last solution works just fine and I am not sure why all of my plugins disappeared. If you have any explanation for this, it would make me very happy.

Thanks for all efforts spent on this!

1 Like


Glad to see you got it working.
No idea why your plugins disappeared.
You must be running an old version of Docker. Docker 1.12?

docker image build works fine starting with Docker 1.13 and is the preferred syntax.
docker build still works though.

Docker restructured the commands and added “sub-commands” in Docker Version 1.13.
Look for CLI restructured in the link below.

Then Docker changed it’s versioning scheme and went to
The next version after 1.13 became 17.03. (i.e. 2017 March).

 $ docker image build -t gforghetti/wordpress:latest .
Sending build context to Docker daemon  18.43kB
Step 1/2 : FROM wordpress:latest
latest: Pulling from library/wordpress
6ae821421a7d: Pull complete
08f3d19635b0: Pull complete
dc8a54b8000b: Pull complete
b2c1d103db99: Pull complete
edfa752aa38a: Pull complete
583d37cbf2f0: Pull complete
c7846a240c1d: Pull complete
d8f9f0fd02fe: Pull complete
01d43e56770d: Pull complete
dbe439e2caf9: Pull complete
3de30e1f5211: Pull complete
209dd35ef060: Pull complete
3d97847926b1: Pull complete
e2dfaa5afe2c: Pull complete
c39665b60f96: Pull complete
f36ef5821516: Pull complete
c96693ff91d0: Pull complete
2e00dc04ad85: Pull complete
Digest: sha256:3a71e9cc138f936d5eda53b776dff9f2630daeaab023e8ba506faa75fec98073
Status: Downloaded newer image for wordpress:latest
 ---> 7539ce0f28d0
Step 2/2 : RUN touch /usr/local/etc/php/conf.d/uploads.ini     && echo "upload_max_filesize = 10M;" >> /usr/local/etc/php/conf.d/uploads.ini
 ---> Running in b3319a465fc2
Removing intermediate container b3319a465fc2
 ---> c92ea6d743fb
Successfully built c92ea6d743fb
Successfully tagged gforghetti/wordpress:latest
🐳  gforghetti:[~/Vagrants/Docker-EE-UCP-Cluster/Docker_Apps/Linux/Wordpress] $

I think the best thing for you would be to mount that file from outside of the container.
I would do t he same with plugin directory, so you won’t loose those either.

You can find more details about mounting files from outside of the container in “volumes” section of compose documentation.


I tried that. The directory /usr/local/etc/php is not defined as a volume in the wordpress default Dockerfile so no way to add that.

$ docker image inspect wordpress:latest --format '{{.Config.Volumes}}'

I tried another method of modifying the uploads by a config file addition to the /var/www/html directory with a volume mount of the file. The directory was overwritten by the PHP initialization and the file was gone.

I think I might know what happened to your Plugins.
The Plugins were installed in a file system in the PHP container file system I’m thinking.
PHP might have set some entries in the MySQL database indicating the Plugins were installed.
You brought down the stack with docker-compose down but you did not specify the -v argument which tells docker to remove the persistent volume (for the MySQL database). So the MySQL database was not deleted. You brought the stack back up with docker-compose up. The MySQL server will use the same database as it’s still on the persistent volume. Wordpress came up, queried the MySQL database, found out that Plugins were previously installed but were no longer in the wordpress container filesystem as a brand new container was launched. The Wordpress docker image does have a volume for /var/www/html but unless it is mounted in the docker-compose.yml file, that directory does not persist.


Yes, Wordpress/PHP stores data in the /var/www/html directory.

I modified my copy of the docker-compose.yml file to add a volume and mount for that directory so it persists.


version: '3.4'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

       - db
     image: gforghetti/wordpress:latest
       - php_data:/var/www/html
       - "8000:80"
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
    db_data: {}
    php_data: {}

That is the same conclusion I came up with before reading your post. The added plugins (added after the wordpress image was built) are indeed stored on the file system (see and will be lost on each “docker compose” run. This same article mentions the following very relevant facts:

Some of these folders may contain important files. Like the gallery folder may contain your gallery images. You should always backup such folders to avoid losing important data.

Other folders may contain files that you can safely delete. For example your caching plugins like W3 Total Cache or WP Super Cache may store cached files in their own folders.

So, my question is this: does the modified docker-compose.yml with added

       - php_data:/var/www/html

cover all cases of modifyng the running containers (adding plugins, themes, etc)?

Yes, that volume is persisting the Wordpress root directory /var/www/html.

Hi @gforghetti

The added data to the YAML file is not sufficient, as the new limit for uploads set as

RUN touch /usr/local/etc/php/conf.d/uploads.ini \
    && echo "upload_max_filesize = 10M;" >> /usr/local/etc/php/conf.d/uploads.ini

which you introduced above is not taking care of the /usr/local/etc/php/conf.d folder.

Note that I am not nitpicking here - my intent is to finish this discussion in a way that will provide the good solution for anyone who decides to use Docker to install wordpress.

Try increasing the value to what you think you want the maximum to be for your Wordpress site.
Below is for 1024M. I’m pretty sure the value has to be in megabytes.

upload_max_filesize = 1024M

I believe that you misunderstood my today’s remark, so I will restate it this way: the file
/usr/local/etc/php/conf.d/uploads.ini should also be persisted the same way as the folder /var/www/html

Making sense?

I think for the /usr/local/etc/php directory, the better wording is to have it exposed as a volume so you can do a bind mount and specify overrides. Nothing in that directory is modified at run time so no need for you to define it on an external volume and make it persistent.

You can open a GitHub issue here ->

Tell them you want the Docker Official Wordpress Docker Image to expose the /usr/local/etc/php directory as a volume mount point so you (and other users) can bind mount your own customization files at container run time.

Very good observation (Nothing in that directory is modified at run time), @gforghetti :clap:

I stand corrected and grateful for your time spent helping me to resolve my problem. The good side-effect is that this solution will help many other folks that undoubtedly follow.

I created this issue at the suggested GitHub repo and will update this thread once that issue gets resolved.

The final thread with the solution in the form of the YAML file for the composer is here.

Yes, that looks good and no need for you to build a custom docker image. I had tried that previously and it did not work for me. I probably had a typo on the target side of the mount.

I’ll give that a try myself.


Hi, I tried the solution that was identified in the GitHub Issue response and it worked for me too.


@gforghetti can you do a little magic and make the reference to this solution appear in the original article ( that led me to get in touch with you and then with the wordpress library folks at ?

Find the PHP.ini file in root directory.If you not see the file select the option “Show hidden files” then the PHP.ini file will be visible. After that add this code in PHP.ini

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 30M

Also edit .htaccess file and add this code

php_value upload_max_filesize 20MB
php_value post_max_size 25MB
php_value memory_limit 30MB

Another method is to modify the WordPress file wp-config.php or functions.php files, and paste the following lines of code

@ini_set( ‘upload_max_size’ , ’20MB’ );
@ini_set( ‘post_max_size’, ’25MB’);
@ini_set( ‘memory_limit’, ’30MB’ );

If you still having an issue I will refer you to a guide where you ca easily learn how to increase upload size limit

Hi gary use this docker-compose.yml file and in same folder create two folder with name “database” and “html” and one file name “uploads.ini”
fire up the compose file

version: ‘3.3’




   - db

 image: wordpress:latest


   - ./html:/var/www/html

   - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini


   - "80:80"

 restart: always



   WORDPRESS_DB_USER: wordpress



 image: mysql:5.7


   - ./database:/var/lib/mysql

 restart: always


   - 3306:3306



   MYSQL_DATABASE: wordpress

   MYSQL_USER: wordpress

   MYSQL_PASSWORD: wordpress


 image: phpmyadmin/phpmyadmin


   - db

 restart: always


   - 3333:80


   PMA_HOST: db

   MYSQL_ROOT_PASSWORT: wordpress  


   - ./uploads.ini:/usr/local/etc/php/conf.d/php-phpmyadmin.ini


my uploads.ini file look like that…

file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600
max_file_uploads = 50000
max_execution_time = 5000
max_input_time = 5000

I added php.ini inside my wordpress folder and it worked.

    upload_max_filesize = 256M
    post_max_size = 256M
    memory_limit = 256M