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

The biggest risk of 5G networks

The fifth generation (5G) network has the potenti...

How 5G frequencies affect range and speed

Experts say that while 5G technology is a huge im...

A brief introduction to intent-based networking (IBN)

In campus networks, there are many emerging trend...

Ten questions about the issuance of 5G temporary licenses: how far is 5G?

Recently, authoritative information about 5G has ...

The Complete Guide to WiFi Penetrating Walls

[[250378]] 1. WiFi Penetration Through Walls: Que...

Detailed explanation of Tomcat HTTP protocol and AJP protocol

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

...