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

Recommend

Internet services for the elderly have been standardized

In order to help key groups such as the elderly a...

5G accelerates the process of 2G/3G network withdrawal in my country

Recently, British mobile operator Three UK has de...

Network programming - starting from establishing a TCP connection

[[388071]] Preface Network programming is somethi...

5G deployment plan postponed to 2021, will operators agree?

In 2020, the sudden outbreak of COVID-19 is havin...

Top 10 SDN Solutions of 2018 (So Far)

Software is the front and center of the network w...

1Gbps ultra-high-speed broadband will be available in some cities next year

On December 26, the National Industrial and Infor...