我分别用两种linux系统部署Docker0.8,都没法限制容器的内存大小。具体情况如下:
# docker run -i -t -d -m 512m centos /bin/bash
WARNING: WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
9229fe1bac59992337e909cbc5a11f3e0fa81553ad7b136bec95a62181a251fd
该容器新建成功,但不能限制内存大小。
# sudo docker run -i -t -m 512m -d ubuntu /bin/bash
89d629ed37d63b67b49ed8c4c11cab653d61d5b85227bdd10c8a9a0a718c686e
看似未报错,登陆该新建的容器里面查看内存【free命令】,发现并未限制。
大家手头的主机都是什么系统,有没有这种情况?如何解决?盼回复,谢谢!
The memory on
in the
free
命令,看的是Host
container.To check the memory limit of
You can also check the restrictions of other resources undercontainer
use this:/cgroup/
:Owner, I also encountered this problem when I was doing experiments with Ubuntu virtual machine. Please refer to here to solve it
http://docs.docker.com/articles/runmetrics/
The following are key excerpts
If you want to enable memory and swap accounting, you must add the following command-line parameters to your kernel:
On systems using GRUB (which is the default for Ubuntu), you can add those parameters by editing
/etc/default/grub
and extendingGRUB_CMDLINE_LINUX
. Look for the following line:And replace it by the following one:
Then run
sudo update-grub
, and reboot.These parameters will help you get rid of the following warnings:
Does anyone know how to solve this problem on Centos6?
My docker is 1.6.2, Centos is 6.6, and the kernel version is 3.10.81
@colin5063
I am CentOS6.7, it should be almost the same
I modified it
/etc/grub.conf
在当前使用的内核的kernel项的最后加上cgroup_enable=memory swapaccount=1
reboot
Then
cat /proc/cmdline
you will find that the configuration has taken effect