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

API requests are slow? This time the backend is not to blame

question During the development process, we found...

50% of global data center Ethernet switches will be 25GbE or 100GbE by 2021

According to the latest survey report titled &quo...

Software testing requires understanding of these network knowledge points

1. Network Classification Telecommunications netw...

Three considerations to spark innovation on the modern web

Today’s networks may not adapt well to changing n...

5G is not here yet, but it is within reach

5G is currently the most eye-catching new technol...

Wi-Fi 6E: When will it arrive? What will be the impact?

Wi-Fi 6E: When is it coming? New wireless spectru...

After talking so much about 5G, the most critical technology is here

When it comes to antennas, everyone must be famil...

...

The relationship and difference between URL, URI and URN

URL Uniform Resource Locator (URL) is a reference...

How to ensure wireless network infrastructure supports Wi-Fi 6/6E?

As the use of wireless devices continues to soar ...