Home > Operation and Maintenance > Docker > What should I do if docker cannot access the external network?

What should I do if docker cannot access the external network?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2022-08-16 17:22:29
Original
14814 people have browsed it

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.

What should I do if docker cannot access the external network?

The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.

What should I do if docker cannot access the external network?

1. Problem

The host machine can access the external network normally, but it cannot be accessed from the container created by docker External network

What should I do if docker cannot access the external network?

2. Solution

Method 1: Rebuild the networkdocker0

sudo service docker stop
sudo pkill docker
sudo iptables -t nat -F
sudo ifconfig docker0 down
sudo brctl delbr docker0
sudo service docker start
Copy after login

What should I do if docker cannot access the external network?

Method 2: Enable the host’s ipv4 forwarding function

# 修改配置
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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
About docker
From 1970-01-01 08:00:00
0
0
0
docker install phpstudy
From 1970-01-01 08:00:00
0
0
0
Deploy snmp environment in docker
From 1970-01-01 08:00:00
0
0
0
docker: invalid reference format
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template