docker info 檢視報錯 WARNING: No swap limit support 解決
阿新 • • 發佈:2021-12-10
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