目录

IPv4 forwarding is disabled. Networking will not work

问题

今天在操作 docker 时遇到了一个问题IPv4 forwarding is disabled. Networking will not work👇

https://cdn.xiaobinqt.cn/xiaobinqt.io/20220508/e1bf06fd0d134476833680c7c412da4a.png?imageView2/0/q/75|watermark/2/text/eGlhb2JpbnF0/font/dmlqYXlh/fontsize/1000/fill/IzVDNUI1Qg==/dissolve/52/gravity/SouthEast/dx/15/dy/15
报错信息

我的系统是 CentOS7.9

https://cdn.xiaobinqt.cn/xiaobinqt.io/20220508/bd163e7f159544fb82224f0e6e37fbf6.png?imageView2/0/q/75|watermark/2/text/eGlhb2JpbnF0/font/dmlqYXlh/fontsize/1000/fill/IzVDNUI1Qg==/dissolve/52/gravity/SouthEast/dx/15/dy/15
系统信息

解决方案

在宿主机执行

1
echo "net.ipv4.ip_forward=1" >>/usr/lib/sysctl.d/00-system.conf

然后重启网络和 docker

1
2
systemctl restart network
systemctl restart docker

https://cdn.xiaobinqt.cn/xiaobinqt.io/20220508/a8321d29039d48be9106c0ad5ba07f35.png?imageView2/0/q/75|watermark/2/text/eGlhb2JpbnF0/font/dmlqYXlh/fontsize/1000/fill/IzVDNUI1Qg==/dissolve/52/gravity/SouthEast/dx/15/dy/15
问题解决