moby: Swap limit capabilities failure while trying to set memory limit

Hi guys,

I’m trying to set memory limit on docker commit using the -run option, e.g.:

docker commit  -run='{"Memory": 128}' 0b5e63a76024 flaviamissi/test

This works as expected, but when I attempt to run a container using the obtained image I get the following:

$ docker run -t -i tsuru/test /bin/bash
WARNING:  Your kernel does not support memory swap capabilities. Limitation discarded.
lxc-start: Device or resource busy - write /sys/fs/cgroup/memory/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff/memory.limit_in_bytes : Device or resource busy
lxc-start: Error setting memory.limit_in_bytes to 128 for lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff

lxc-start: failed to setup the cgroups for '5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: failed to spawn '5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/cpuset/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/cpu/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/cpuacct/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/memory/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/devices/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'
lxc-start: Device or resource busy - failed to remove cgroup '/sys/fs/cgroup/freezer/lxc/5e29ddc69751e982fd1895e5d8b8f3159184ab9859c2bc3747b6c16d17a9e1ff'

What is puzzling me is the warning printed by docker:

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

If you pay attention, I’m not setting the MemorySwap option, but the Memory opt.

I’ve found the code that logs it, and it seems that the check is wrong, see:

if container.Config.Memory > 0 && !container.runtime.capabilities.SwapLimit {
...

What should be really checked here isn’t the container.Config.MemorySwap attribute?

Would someone mind to clarify this to me?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

But so that you are not worried about it any long you need to boot the kernel with these parameters cgroup_enable=memory swapaccount=1.

To do that you would need to edit your /etc/default/grub file and set this

GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"