6 solutions to the problem of no Internet access in Docker containers

6 solutions to the problem of no Internet access in Docker containers

Note: The following method is a solution that allows you to ping the public IP in the container. If you cannot ping the public IP, the host may not be able to access the Internet (try ping 8.8.8.8).

[[286543]]

1. Use the –net:host option

  1. sudo docker run –net:host –name ubuntu_bash -i -t ubuntu:latest /bin/bash

2. Use the –dns option

  1. sudo docker run –dns 8.8.8.8–dns 8.8.4.4–name ubuntu_bash -i -t ubuntu:latest /bin/bash

3. Change DNS server

  1. vi /etc/default/docker
  2. # Remove the # sign beforedocker_OPTS =”–dns 8.8.8.8 –dns 8.8.4.4″”

4. No need for dnsmasq

  1. vi /etc/
  2. NetworkManager
  3. /
  4. NetworkManager
  5. .conf
  6. # Add a # before dns = dnsmasq to comment it out, then
  7.  
  8. sudo restart network-manager
  9. sudo restart docker

5. Rebuild the docker0 network

  1. pkill docker
  2. iptables -t nat -F
  3. ifconfig docker0 down
  4. brctl delbr docker0
  5. docker -d

6. Modify /etc/hosts directly in docker

<<:  Are the operating data of the three major operators good with number portability and 5G commercial use?

>>:  IPv6 basics, learn in one minute

Blog    

Recommend

SPI Subsystem SPI Driver

1. SPI driver source file directory Linux common ...

Detailed explanation of Tomcat HTTP protocol and AJP protocol

The main function of Tomcat is to provide a Servl...

Five technical challenges in deploying IoT networks

Network architects and system engineers beware—ge...

No wonder 4G is faster than 5G now. The secrets of 4G you don’t know

I don’t know if you have noticed that it is obvio...

Five-minute technical talk | AI technology and the governance of "cyber violence"

Part 01 What is “cyberbullying”? "Cyber ​​vi...