I got this error today while trying to upgrade some php application:
Fatal error encountered: /var/www/html/libs/Zend/Db/Statement/Pdo.php(292): Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
UPS :) Quick! Go check your memory limits... pull your hair out, run around the house senseless! WE ARE DOOMED!
Well, the fix is easy. Read on (or watch the video).
Demo
Check out my channel for other interesting videos.
1. Confirm the current php memory limit:
# php -r "echo ini_get('memory_limit').PHP_EOL;"
2. Create a new configuration file or add in an existing one, in /usr/local/etc/php/conf.d/:
# echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker-php-ram-limit.ini
3. Check if memory limit was changed:
# php -r "echo ini_get('memory_limit').PHP_EOL;"
THIS MODIFICATION IS INSTANT - no need to restart anything. Cute, right? :)
However, do read what follows.
To avoid running this every time you recreate/restart the container (on restart this is erased too), you can create a custom image by adding what follows to the dockerfile:
RUN cd /usr/local/etc/php/conf.d/ && \ echo 'memory_limit = -1' >> /usr/local/etc/php/conf.d/docker-php-ram-limit.ini