Docker info 查看报错 WARNING: No swap limit support 解决

docker可以通过启动命令来限制容器可以使用的最大物理内存和swap,但是通常在使用这些命令的时候经常会碰到“WARNING: No swap limit support”警告

大概意思就是不支持swap内存的限制,所以在使用,在国内的腾讯云和阿里云服务器上测试都是报这个警告的。

限制docker容器最大内存使用量

参数:-m 64M --memory-swap=128M

-m 64M 限制了容器运行可以使用的最大物理内存为64M,--memory-swap=128M限制容器可以使用的最大虚拟内存为128M,在出现WARNING: No swap limit support警告时这两个参数是无效的。

解决方法:

1、编辑/etc/default/grub文件。

在GRUB_CMDLINE_LINUX=" ",中并追加 cgroup_enable=memory swapaccount=1 

yang@master:~$ cat  /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity"
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"

注:如果GRUB_CMDLINE_LINUX=内有内容,切记不可删除,只需在后面追加cgroup_enable=memory swapaccount=1并用空格和前面的内容分隔开。

2、保存,更新

yang@master:~$  sudo update-grub

3、重启服务器

yang@master:~$ sudo reboot

4、查看

yang@master:~$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
.....
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

 

原文地址:https://www.cnblogs.com/yangzp/p/15672475.html