1

I have tried to run 'composer update' command inside docker container in Aws ec2 instance. But I get this error

  mmap() failed: [12] Cannot allocate memory

  mmap() failed: [12] Cannot allocate memory

  Fatal error: Out of memory (allocated 478179328) (tried to allocate 20996408 bytes) in phar:///usr/local/bin/composer/src/Composer/Util/RemoteFilesystem.php on line 462

I have tried using "memory_limit = -1" or "memory_limit = 2G" in the php configaration file. I have also tried to run this command "php -d memory_limit=-1 /usr/local/bin/composer update" inside my docker container. But it still shows the same error

X_slasher
  • 61
  • 10
  • Does this answer your question? [PHP Composer update "cannot allocate memory" error (using Laravel 4)](https://stackoverflow.com/questions/18116261/php-composer-update-cannot-allocate-memory-error-using-laravel-4) – Nico Haase May 13 '20 at 12:00

1 Answers1

4

Run composer update in your local environment, then commit composer.json and composer.lock to your code repository, pull the changes in your ec2 instance and run composer install.

Commonly, low resource servers don't have enough RAM to run composer update. You're better off doing it in your local environment, and only using composer install on your server.

Joundill
  • 6,828
  • 12
  • 36
  • 50
  • I have firstly run "composer update" in my local enviorment and the commit the code to github and then clone the project in Aws ec2 container. Then run "docker-compose up -d" to run the container and the instde the container run "composer update" command – X_slasher May 13 '20 at 08:50
  • 3
    Don't run `composer update` inside the container. That's your problem, and there's no real point. Run `composer install` instead. – Joundill May 13 '20 at 08:52