Docker – how can i modify max memory-limit in php.ini in docker container

dockermac

within the docker container on a MAC, I am getting a php memory error :

Fatal error:  Allowed memory size of 404750336 bytes exhausted (tried to allocate 266342400 bytes

how can i find where the php.ini file is or how can i modify this parameter in docker?

Best Answer

Depends on the image, but usually it's enough to do

ENV PHP_MEMORY_LIMIT=128M

inside the Dockerfile.

Beware: the unit is a single letter, M for MB (or G for GB).
Otherwise it will silently ignore the value and keep the default limit (64M? Do a RUN echo $PHP_MEMORY_LIMIT to know it).
I often fall in that trap because of habit.