Docker内无法访问外网¶
方法1:重建网络docker0¶
sudo service docker stop
sudo pkill docker
sudo iptables -t nat -F
sudo ifconfig docker0 down
sudo brctl delbr docker0
sudo service docker start
方法2:开启宿主机的ipv4转发功能¶
# 修改配置
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
# 重启network
systemctl restart network
# 查看 (0->标识未开启 1->标识开启)
sysctl net.ipv4.ip_forward
# net.ipv4.ip_forward = 1
# 重启docker
systemctl restart docker