Linux – Not able to set memory limit on containers in docker

dockerlinux

I am using ubuntu 14.04 with latest docker.

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04

3.18.5-x86_64-linode52 kernel

But when i try to set the memory

-m="512m" 
-c=512 

Then i get this error

WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.

Best Answer

Pass cgroup_enable=memory to grub. Preferred way is to create a file in /etc/default/grub.d:

cat > /etc/default/grub.d/memory.cfg <<EOF
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX cgroup_enable=memory"
EOF
  • run update-grub2
  • reboot

After reboot cgroups should be mounted under /sys/fs/cgroup/memory/.