Composer install during docker image build: Allowed memory size exhausted


I’m building docker images and during the build, I run composer to install drupal ( As we all know composer uses a lot of memory and I often hit the limit (1.5G):

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108864 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223


I don’t have a limit on PHP CLI commands (set to -1), so I guess the problem is the docker memory limitation. Is there a way to increase it?

Thank you.

Have you tried

Are you sure about this? The Composer documentation you point to indicates that 1.5 GB is the default, so whatever you think you are doing may not be effective. Please double check that.

We are also happy to enable the debug feature on this repository, so you can troubleshoot more interactively.

Thank you. Adding COMPOSER_MEMORY_LIMIT=-1 helped. Had no idea composer had its own memory limit.