Docker 安装后调整快速起步
当完成 Linux环境安装Docker 后,对于 Debian 系发行版,执行 docker info
有4行警告信息:
docker info
显示不支持内存和swap限制的警告WARNING: No memory limit support
WARNING: No swap limit support
docker info
显示 bridge-nf-call-iptables
被禁止的警告WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
解决方法如下
Docker内核支持cgroup内存和 swap限制
如果是使用 GRUB ( Gentoo GRUB / Ubuntu修订Grub内核启动参数 ) 的常规X86系统,则修改
/etc/default/grub
,添加GRUB_CMDLINE_LINUX
行内容添加如下2个键值对,然后执行update-grub
更新grub之后重启系统生效:
配置
/etc/default/grub
,添加 GRUB_CMDLINE_LINUX
行内容GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
如果使用 Raspberry Pi Raspbery Pi OS(Raspbian) 则直接修订
/boot/firmware/cmdline.txt
在最后添加:
树莓派修订
/boot/firmware/cmdline.txt
激活cgroup内存和swap限制cgroup_enable=memory cgroup_memory=1 swapaccount=1
docker info 显示 bridge-nf-call-iptables 禁用的处理
确保加载
br_netfilter
模块( Debian 系需要):
加载
br_netfilter
内核模块modprobe br_netfilter
echo "br_netfilter" >> /etc/modules-load.d/br_netfilter.conf
执行以下命令为Docker的host主机启用
bridge-nf-call-iptables
(内核参数1
):
启用
bridge-nf-call-iptables
(内核参数 1
)cat << EOF > /etc/sysctl.d/bridge.conf
net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1
EOF
sysctl -p /etc/sysctl.d/bridge.conf