Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker memory-swap=-1 OOM

I'm using Ubuntu14.04 and docker1.10.3.

When I execute docker run with --memory-swap -1, I find the memory used of the host machine is beyond the max memory that that container can use and there's no other processes on the host machine that consume much memory. The follwoing image is the test that I conduct on my computer:

enter image description here

The 1st section is the memory usage on the host machine.
The 2nd section is the test that is runned in the container to simulating using 900M memory in the container using stress.
The 3rd section is using docker stats to see the current stats of the container.

I found that although docker stats shows that the container use no more than 104.9M memory, on the host machine the memory used is far more than 104.9M. It seems that --memory-swap -1 allows the container uses as much memory as it can.

Is it true?

like image 972
flyer Avatar asked Mar 12 '23 02:03

flyer


1 Answers

Yes, you are absolutely right.

You can find more (although exactly this question is not covered so clear there) in docker references.

--memory-swap="" Total memory limit (memory + swap, format: <number>[<unit>]). Number is a positive integer. Unit can be one of b, k, m, or g.

--memory-swap -1 ...disabled swap memory limit, this means the processes in the container can use as much swap memory as they need (if the host supports swap memory).

In case you wanted to disable swap usage of container you could use

--memory-swap=0

like image 177
Evedel Avatar answered Mar 19 '23 02:03

Evedel