我分別用兩種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命令】,發現並未限製。
大家手頭的主機都是什麼係統,有沒有這種情況?如何解決?盼回複,謝謝!
container中的
free
命令,看的是Host
上的記憶體。要看
container
的記憶體限制用這個:/cgroup/
下方還可以查看其它資源的限制:樓主,我用ubuntu虛擬機做實驗的時候也遇到這個問題,請參考這裡解決
http://docs.docker.com/articles/runmetrics/
以下是重點摘錄
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:
有人知道Centos6下面這個問題要怎麼解決?
我的docker是1.6.2的, Centos是6.6,核心版本是3.10.81
@colin5063
我是CentOS6.7 應該差不多
我是修改的
/etc/grub.conf
在当前使用的内核的kernel项的最后加上cgroup_enable=memory swapaccount=1
reboot
然後
cat /proc/cmdline
就會發現,配置生效了