Docker php image has no php.ini and my edits do not stay
No php.ini file in the PHP container, only php.ini-development and php.ini-productionShort answer
The official php image ships php.ini-development and php.ini-production but no active php.ini. Copy one to php.ini, or add your own .ini file under conf.d, in the Dockerfile. An edit made inside a running container is lost when the container is recreated.
Fix it fast
1Find out which cause you have
Ask PHP which files it loaded. This shows whether a php.ini is active and which extra files are read.
docker compose exec php php --ini2Match what you see, then jump to its fix
What does the error look like?
No php.ini file in the PHP container, only php.ini-development and php.ini-productionA setting changed in php.ini inside the container is gone after the container is recreated
Cause 1 of 2
There is no php.ini, only the two templates
1Check
The image documentation says it ships the two template files and refers to the configuration folder as $PHP_INI_DIR. Nothing is active until you create it.
docker compose exec php sh -c 'ls "$PHP_INI_DIR"'2Fix
Create the real file in the Dockerfile. The documentation recommends the production template for images used in production.
FROM php:8.3-fpm
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"3Verify
Rebuild and check that a php.ini is now loaded.
docker compose build php
docker compose run --rm php php --iniConfirmed by raw.githubusercontent.com
Cause 2 of 2
The edit was made inside a container and the container was recreated
1Check
Docker's storage documentation says data written to the container layer does not persist when the container is destroyed. A new container starts from the image again.
docker compose exec php php -i | grep -i "memory_limit"2Fix
Put the setting in a file that is part of the image. The documentation says to copy configuration files into $PHP_INI_DIR/conf.d/, and PHP reads *.ini files from its scan directory in alphabetical order.
# custom.ini (next to the Dockerfile)
memory_limit = 256M
upload_max_filesize = 20M
# Dockerfile
COPY custom.ini $PHP_INI_DIR/conf.d/custom.ini3Verify
Rebuild, start a fresh container and read the value back.
docker compose up -d --build
docker compose exec php php -r 'echo ini_get("memory_limit");'Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Keep every PHP setting in a file that you COPY into the image, and keep that file in version control.
- Use php.ini-production for production images and php.ini-development locally.
- Run php --ini as part of troubleshooting before editing anything.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Back end
memory_limit does not change inside a PHP Docker container
memory_limit is still 128M after editing php.ini in the container
Your setting is being read from the wrong place or overridden.
4 causes, each with a fixServers
WordPress in Docker keeps the old upload size limit
413 Request Entity Too Large
The wordpress image runs stock PHP, whose default upload limit is 2M with an 8M POST cap.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
docker-php-ext-install mbstring fails: oniguruma not found
The docker-php-ext-install step exits with a non-zero code
mbstring needs the Oniguruma library to build its regex functions, and the PHP build finds it through pkg-config.
3 causes, each with a fixServers
HTTP 414 error: the web server says the URL is too long
414 Request-URI Too Large
A 414 means the server refused the request because the URL is longer than it accepts.
4 causes, each with a fixServers
The MinIO Console will not work behind an nginx proxy: no login, 403 on the WebSocket, or repeated disconnects
The Console UI shows repeated disconnects
Behind a proxy the MinIO Console needs three things.
4 causes, each with a fix