Home > other >  How to limit memory size of container
How to limit memory size of container

Time:10-03

I respectively in two Linux system deployment Docker0.8, couldn't limit the memory size container, details are as follows:

Use CentOS6.5 [kernel 3.10.5-3. El6. X86_64] do the host, the new container, the results are as follows:
# docker run - I - t - d - m 512 m centos/bin/bash
WARNING: WARNING: Your kernel does not support swap limit "capabilities. The Limitation discarded.
9229 fe1bac59992337e909cbc5a11f3e0fa81553ad7b136bec95a62181a251fd
The container of new success, but not limited memory size,

Ubuntu 12.04 [kernel 3.8.0-38 - generic] do the host, and modify the/etc/default/grub, change $GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1", after the new container, the results are as follows:
# sudo docker run - I - t - 512 m - m d ubuntu/bin/bash
89 d629ed37d63b67b49ed8c4c11cab653d61d5b85227bdd10c8a9a0a718c686e
Seems not an error, in the new container for memory [free command], found that does not limit,

Host is what you use the system, this kind of situation? How to solve? Looking forward to reply, thank you!

CodePudding user response:

The free command of the container, is the memory on the Host,

To see the memory limit of the container with this:

The cat/cgroup/memory/LXC/{full_container_id}/memory. Limit_in_bytes

/cgroup/under restrictions can also see other resources:

Ll/cgroup/
The total dosage of 0
DRWXR xr - x 3 root root 0 March 17 blkio therefore
DRWXR xr - x 3 root root 0 March 17 "CPU
DRWXR xr - x 3 root root 0 March 17 cpuacct therefore
DRWXR xr - x 3 root root 0 March 17 cpuset therefore
DRWXR xr - x 3 root root 0 March 17 devices therefore
DRWXR xr - x 3 root root 0 March 17 "freezer
DRWXR xr - x 3 root root 0 March 17 memory therefore
DRWXR xr - x 3 root root 0 net_cls therefore on 17 March
  • Related