亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

docker - 如何限制容器內(nèi)存大???
怪我咯
怪我咯 2017-04-21 10:56:38
0
4
949

我分別用兩種linux系統(tǒng)部署Docker0.8,都沒(méi)法限制容器的內(nèi)存大小。具體情況如下:

  1. 用CentOS6.5【內(nèi)核為3.10.5-3.el6.x86_64】做主機(jī),新建容器,得到結(jié)果如下:
# docker run -i -t -d -m 512m centos /bin/bash   
WARNING: WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
9229fe1bac59992337e909cbc5a11f3e0fa81553ad7b136bec95a62181a251fd

該容器新建成功,但不能限制內(nèi)存大小。

  1. Ubuntu 12.04【內(nèi)核為3.8.0-38-generic】做主機(jī),并且修正/etc/default/grub,更改$ GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"之后,新建容器,得到結(jié)果如下:
# sudo docker run -i -t -m 512m -d ubuntu /bin/bash
89d629ed37d63b67b49ed8c4c11cab653d61d5b85227bdd10c8a9a0a718c686e

看似未報(bào)錯(cuò),登陸該新建的容器里面查看內(nèi)存【free命令】,發(fā)現(xiàn)并未限制。

大家手頭的主機(jī)都是什么系統(tǒng),有沒(méi)有這種情況?如何解決?盼回復(fù),謝謝!

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(4)
劉奇

The memory on

in the free命令,看的是Hostcontainer.

To check the memory limit of container use this:

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

You can also check the restrictions of other resources under

/cgroup/:

ll /cgroup/
總用量 0
drwxr-xr-x 3 root root 0 3月  17 13:33 blkio
drwxr-xr-x 3 root root 0 3月  17 13:33 cpu
drwxr-xr-x 3 root root 0 3月  17 13:33 cpuacct
drwxr-xr-x 3 root root 0 3月  17 13:33 cpuset
drwxr-xr-x 3 root root 0 3月  17 13:33 devices
drwxr-xr-x 3 root root 0 3月  17 13:33 freezer
drwxr-xr-x 3 root root 0 3月  17 13:33 memory
drwxr-xr-x 3 root root 0 3月  17 13:33 net_cls
洪濤

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:

$ cgroup_enable=memory swapaccount=1

On systems using GRUB (which is the default for Ubuntu), you can add those parameters by editing /etc/default/grub and extending GRUB_CMDLINE_LINUX. Look for the following line:

$ GRUB_CMDLINE_LINUX=""

And replace it by the following one:

$ GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

Then run sudo update-grub, and reboot.

These parameters will help you get rid of the following warnings:

WARNING: Your kernel does not support cgroup swap limit.
WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.
大家講道理

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 在當(dāng)前使用的內(nèi)核的kernel項(xiàng)的最后加上cgroup_enable=memory swapaccount=1

reboot

Then cat /proc/cmdline you will find that the configuration has taken effect

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template