I am proposing to expose the /usr/local/etc/php directory one can do a bind mount and specify overrides.
This proposal comes as a summary of the discussion at https://forums.docker.com/t/how-to-get-access-to-php-ini-file/68986?u=monterey, trying to define the simplest method for solving the error condition The uploaded file exceeds the upload_max_filesize directive in php.ini
This also will also users to specify a custom php.ini file at container run time.
Traditionally users would mount a custom.ini in the $PHP_INI_DIR/conf.d/, it looks like the WordPress documentation doesn't direct users to the php docs for information on configuring the image.
There was also this previous discussion on changing the upload file size limit https://github.com/docker-library/wordpress/issues/10#issuecomment-66906071
uploads.ini
file_uploads = On
upload_max_filesize = 256M
post_max_size = 256M
docker-compose.yml
version: '3.6'
services:
mysql:
image: mysql
command: --default-authentication-plugin=mysql_native_password
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_PASSWORD: 123
wordpress:
image: wordpress:latest
container_name: wordpress
volumes:
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_NAME: db
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: 123
Checking the changes
$ docker-compose up -d
Creating network "wordpress-375_default" with the default driver
Creating wordpress ... done
Creating mysql ... done
$ docker exec wordpress php -i | grep upload
/usr/local/etc/php/conf.d/uploads.ini
file_uploads => On => On
max_file_uploads => 20 => 20
upload_max_filesize => 256M => 256M
. . .
Indeed, as @wglambert mentions (and shows), the officially supported way to adjust this value in this image is the same as the way to do so on any PHP install, namely adjusting php.ini through any of the various methods PHP provides to do so (which is out of scope for us to document).
Happy to see that this is successfully closed with the solution that is "WordPress standard" (read: I did not want to just patch it any way that I could think of, but tried instead to keep the issue alive until it gets proper cure 馃槃
Most helpful comment
uploads.ini
docker-compose.yml
Checking the changes