How do I limit the size of the container memory?

  docker, question

I deployed Docker0.8 with two linux systems respectively, and neither could limit the memory size of the container. The details are as follows:

  1. Using CentOS6.5 [kernel is 3.10.5-3.el6.x86_64] as host, create a new container. The results are as follows:
# docker run -i -t -d -m 512m centos /bin/bash
 WARNING: WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
 9229fe1bac59992337e909cbc5a11f3e0fa81553ad7b136bec95a62181a251fd

The container was successfully created, but the memory size cannot be limited.

  1. Ubuntu 12.04 [kernel is 3.8.0-38-generic] as host, and after correcting /etc/default/grub and changing $ grub _ cmdline _ Linux = “CGROUP _ ENABLE = memoryswap account = 1”, create a new container. The results are as follows:
# sudo docker run -i -t -m 512m -d ubuntu /bin/bash
 89d629ed37d63b67b49ed8c4c11cab653d61d5b85227bdd10c8a9a0a718c686e

It seems that there is no error. Log into the newly-built container to check the memory [free command], and it is found that there is no limit.

What kind of systems do you have on hand? Is this the case? How to solve it? Looking forward to your reply, thank you!

In containerfreeThe order, look at isHostMemory on.

To viewcontainerThe memory limit for is this:

cat /cgroup/memory/lxc/{full_container_id}/memory.limit_in_bytes

/cgroup/You can also view the limitations of other resources under:

ll /cgroup/
 Total consumption 0
 DRWXR-XR-X3 ROOT 0 March 17 13:33 blkio
 DRWXR-XR-X3 ROOT 0 March 17 13:33 cpu
 DRWXR-XR-X3 ROOT 0 March 17 13:33 cpuacct
 DRWXR-XR-X3 ROOT 0 March 17 13:33 cpuset
 DRWXR-XR-X3 ROOT 0 March 17 13:33 devices
 DRWXR-XR-X3 ROOT 0 March 17 13:33 freezer
 DRWXR-XR-X3 ROOT 0 March 17 13:33 memory
 DRWXR-XR-X3 ROOT 0 March 17 13:33 net_cls