I'm getting a warning when I run docker:
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
I'm trying to work out what this means, particularly the phrase "Memory limited without swap."
Does this mean that the container can use more memory than you would normally allow it by using the swap space of the host machine? Or does it mean that the container can't use the swap space, even when the host runs out of memory completely? Is it caused by having no swap space configured? Is it irrelevant if you aren't using swap anyway?
Note: I'm not interested in how to fix it - there are lots of results about that on google. I'm interested in what it means, and why it matters.
The --memory parameter limits the container memory usage, and Docker will kill the container if the container tries to use more than the limited memory.
--memory-swap is a modifier flag that only has meaning if --memory is also set. Using swap allows the container to write excess memory requirements to disk when the container has exhausted all the RAM that is available to it.
Docker Container Memory Limits - Set global memory limit When the container exceeds the specified amount of memory, the container will start to swap. By default, the container can swap the same amount of assigned memory, which means that the overall hard limit would be around 256m when you set --memory 128m .
Set Maximum Memory Access To limit the maximum amount of memory usage for a container, add the --memory option to the docker run command. Alternatively, you can use the shortcut -m . Within the command, specify how much memory you want to dedicate to that specific container.
Docker daemon relies on the following virtual files to implement memory and swap limits:
/sys/fs/cgroup/memory/memory.limit_in_bytes /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes
If your kernel does not support swap memory limit, the second file won't be there, and docker run
won't impose any limitations on the use of the swap space. That way the container is even allowed to use more swap than the -m, --memory
setting, as if --memory-swap
had been set to -1
. Obviously, the container can't use more swap space than you have configured on your system.
However, the warning message is also trying to say that option -m, --memory
will still take effect, and the maximum amount of user memory (including file cache) will be set as intended.
The mentioned cgroup mount point may differ, consult /proc/self/mounts
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With