Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer cannot allocate memory inside container docker

I currently use docker to run my Symfony3. But I get this error when I try to run composer update inside my container (after doing command docker exec -it <name of the bash container>)

[ErrorException]
Proc_open (): fork failed - Can not allocate memory

The composer documentation asks to configure the swap of the machine but I get this error by following the steps of the documentation

/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 (OK)                     
/sbin/mkswap /var/swap.1 (OK)

/sbin/swapon /var/swap.1 (KO) -->
Swapon: /var/swap.1: swapon failed: Operation not permitted

(Even though I'm in root mode)

like image 266
nkweb Avatar asked Mar 03 '26 22:03

nkweb


1 Answers

I finally found the answer to my problem.

You can start by adding space on your virtual machine (default). In my case I switched from 1GB to 2GB.

Then you can, if you wish, launch your container with the option --memory-swap = -1 or a space you have chosen
https://docs.docker.com/engine/admin/resource_constraints/#memory-swap-details

It's OK for me now ;) .

like image 157
nkweb Avatar answered Mar 05 '26 11:03

nkweb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!