场景:
在虚拟机下,我关闭了防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
然后再次启动docker容器时,就报如标题错误:
WARNING:IPv4 forwarding is disabled. Networking will not work
解决办法
vi /etc/sysctl.conf
net.ipv4.ip_forward=1 #添加这段代码
#重启network服务
systemctl restart network && systemctl restart docker
#查看是否修改成功 (备注:返回1,就是成功)
sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1