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

TCP/IP knowledge point: host-to-host layer protocol

Host-to-Host Layer Protocol The main function of ...

In the era of stock management, operators still need to provide refined services

Recently, the three major operators announced the...

Network Slicing "Hot Pot Theory": Same Pot, Different Dreams

In the dog days of summer, when people are "...

5G network deployment brings both opportunities and challenges

5G (or 5th generation mobile networks) deployment...

10 Ways to Use AI for Web Design

【51CTO.com Quick Translation】 Web design is const...

Huawei Enjoy 10S hands-on review: good looks, photography, and battery life

Data released by market research firm QuestMobile...

The Cybersecurity Law was promulgated: 6 highlights

On November 7, the 24th meeting of the Standing C...

...

SIM card swap attacks: an inevitable battle as 5G wave arrives

The infrastructure of mobile phone operators is u...

The fatal factor affecting TCP connection throughput: HOL

1. What is HOL HOL means Head of line blocking. I...