Loading

centos 7 Docker容器启动报WARNING: IPv4 forwarding is disabled. Networking will not work

解决办法:
# vi /etc/sysctl.conf
或者
# vi /usr/lib/sysctl.d/00-system.conf
添加如下代码:
    net.ipv4.ip_forward=1
 
重启network服务
# systemctl restart network
 
查看是否修改成功
# sysctl net.ipv4.ip_forward
 
如果返回为“net.ipv4.ip_forward = 1”则表示成功了
 
这时,重启容器即可。

 systemctl restart docker

 

另外还可以通过run时加-p 参数指定IP的方式来解决,比如 -p 0.0.0.0:999:999(指定ip就按ipv4来,否则默认全部是ipv6的。)

posted @ 2020-08-01 17:58  landfill  阅读(223)  评论(0编辑  收藏  举报