Docker build failed - "cannot allocate memory"

My docker build failed with the following error:

Untar fork/exec /usr/bin/docker: cannot allocate memory 

So, I get this - there is no RAM :), but I can clearly see free memory as a swap:

  total used free shared buffers cached Mem: 7517 7334 183 0 59 515 -/+ buffers/cache: 6759 758 Swap: 4095 2635 1460 

In addition, it seems that the docker takes up a huge chunk of memory:

 $ top -a top - 03:48:07 up 18 days, 17 min, 2 users, load average: 1.88, 0.93, 0.42 Tasks: 127 total, 2 running, 125 sleeping, 0 stopped, 0 zombie Cpu(s): 49.9%us, 14.0%sy, 0.0%ni, 13.7%id, 22.2%wa, 0.0%hi, 0.2%si, 0.0%st Mem: 7697592k total, 6351288k used, 1346304k free, 138804k buffers Swap: 4194300k total, 310324k used, 3883976k free, 1449268k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1340 root 20 0 3994m 2.1g 7548 S 6.6 28.8 64:20.43 docker 5318 root 20 0 1499m 724m 4368 S 65.5 9.6 0:08.80 ruby 978 root 20 0 1010m 616m 32 S 0.0 8.2 0:27.24 ruby 

So the question is:
Why doesn't the docker assembly use the swap space as additional RAM and decide to kill the assembly?

+6
source share
1 answer

It is simple and simple. You have lost your memory. You must free memory by stopping applications.

Swap is usually a thousand times slower than real memory. There are many applications that prohibit their data exchange, for example:

  • Databases usually cause some critical data to not be replaced for execution.

  • Low-level system components, such as kernels and drivers, cannot be replaced for various reasons. (How to read the swap disk if the disk driver has been replaced ?: D)

Docker relies on many low-level primitives to run and manage containers, it is very likely that they must have real memory. Therefore, Docker cannot work when you are out of physical memory.

0
source

All Articles