docker 下网络不通的解决办法

docker网络不通   docker  

进入容器测试网络和解析是否正常

docker exec -i -t   adee2653e44f /bin/bash

# ping www.qq.com  测试解析正常的情况下,如果不通就单独ping IP测试一下

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.  

修改主机sysctl参数

  • vim /etc/sysctl.conf
sysctl -w net.bridge.bridge-nf-call-ip6tables = 1  
sysctl -w net.bridge.bridge-nf-call-iptables = 1  
sysctl -w net.bridge.bridge-nf-call-arptables = 1  
sysctl -w net.ipv4.ip_forward=1  
  • 执行sysctl -p生效

重启docker服务,网络即可以恢复正常

/bin/systemctl restart docker.service