11

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?

Diana
  • 243
  • 1
  • 3
  • 9
  • Depends on the image. There are several common PHP images, and you need to handle the config in different ways depending on how PHP is running in the image. Also, are you sure this is a problem with the PHP limit, and not the amount of memory you have allocated to the Docker VM? – Zoredache Oct 03 '19 at 18:16
  • Please follow the thread here: https://stackoverflow.com/questions/54516509/php-memory-size-exhausted-in-docker-with-magento-bin-setupdicompile and https://github.com/nextcloud/docker/issues/447 There is explanation on how to approach in different ways. In the thread i have tried to explain the docker way. – Ngatia Frankline Jan 15 '20 at 23:22

2 Answers2

4

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.

Kamafeather
  • 165
  • 7
0

Adding the following line inside your Dockerfile do the job for me

RUN echo 'memory_limit = 2048M' >> /usr/local/etc/php/conf.d/docker-php-memlimit.ini;