Home>Article>Operation and Maintenance> What should I do if docker cannot access the external network?
There are two solutions for docker unable to access the external network: 1. Use "service docker stop", "pkill docker" and other operations to rebuild the network docker0; 2. Use "echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf" modify the configuration and enable the host's ipv4 forwarding function.
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
The host machine can access the external network normally, but it cannot be accessed from the container created by docker External network
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
# 修改配置 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
Recommended study: "docker video tutorial》
The above is the detailed content of What should I do if docker cannot access the external network?. For more information, please follow other related articles on the PHP Chinese website!