Home >Operation and Maintenance >Docker >Docker containers cannot access the external network
The Docker container cannot access the external network:
The following situations occur:
The Docker container cannot access the external network
Other machines in the LAN cannot access the docker service
Startup error docker warning ipv4 forwarding is disabled. networking will not work
Solution:
Use the following command to open sysctl.conf File
vi /etc/sysctl.conf
Then add the following code in the sysctl.conf file:
net.ipv4.ip_forward=1
You can use the sysctl net.ipv4.ip_forward command to check whether the modification is successful. The results returned after the modification is successful are as follows:
net.ipv4.ip_forward = 1
Then use the following command to restart the network service:
systemctl restart network
For more related tutorials, please pay attention to the docker tutorial column of the PHP Chinese website.
The above is the detailed content of Docker containers cannot access the external network. For more information, please follow other related articles on the PHP Chinese website!