“IPv4 forwarding is disabled. Networking will not work” 的解决办法

问题描述: docker在构建镜像,创建容器时都会产生下面的提示,一开始并没有把它当一回事;dockerfile中使用yum安装软件一直安装失败,更换yum源依然失败,多次的失败不得不让我关注所有出现的问题。百度一下发现有同样问题的,尝试他的解决办法后yum可以使用了。

报错:
IPv4 forwarding is disabled. Networking will not work

解决:开启路由转发,在docker宿主机上执行如下命令

修改/etc/sysctl.conf文件,添加如下内容:
net.ipv4.ip_forward=1

然后重启网络:
systemctl restart network #查看是否添加成功:
sysctl net.ipv4.ip_forward #输出为1时则证明是成功的,之后创建镜像和端口转发都没有问题了

你可能感兴趣的:(“IPv4 forwarding is disabled. Networking will not work” 的解决办法)