Docker: how to enable swap limit capabilities

root's picture

You try to start your docker container with limits for memory and you get this warning:
Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.

At this point, I assume you have already cgroup working, CPU and RAM is limited and only swap is left.
These steps were done on Debian Buster.

1. Edit /etc/default/grub and update the entry GRUB_CMDLINE_LINUX as follows

root@candy:~# grep GRUB_CMDLINE_LINUX /etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

2. Update grub

root@candy:~# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.0-9-amd64
Found initrd image: /boot/initrd.img-4.19.0-9-amd64
done

3. Reboot

Now you should no more have that warning when starting docker container. Also, your container will have swap limit.
Enjoy!

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root