Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that the docker container cannot ping the public network

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to solve the problem that the docker container cannot ping the extranet. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Today, when building the redis environment in docker, it was found that yum could not pull resources or access the network, and the following error was reported:

Http://mirrors.aliyun.com/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.aliyun.com'

Trying other mirror.

Http://mirrors.neusoft.edu.cn/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.neusoft.edu.cn'

Trying other mirror.

Http://mirrors.nwsuaf.edu.cn/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.nwsuaf.edu.cn'

Trying other mirror.

Http://mirrors.shu.edu.cn/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.shu.edu.cn'

Trying other mirror.

Http://mirrors.sohu.com/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.sohu.com'

Trying other mirror.

Http://mirrors.tuna.tsinghua.edu.cn/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.tuna.tsinghua.edu.cn'

Trying other mirror.

Http://mirrors.zju.edu.cn/centos/6.10/extras/x86_64/Packages/epel-release-6-8.noarch.rpm: [Errno 14] PYCURL ERROR 6-"Couldn't resolve host" mirrors.zju.edu.cn'

Trying other mirror.

Test wget

Wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

As a result, an error was reported

Unknown host mirrors.163.com

Test ping

Inside the container

Ping www.baidu.com

The result is still a failure.

Ping: unknown host www.baidu.com

Open one more terminal, enter the host (not the container), and test the ping command to find that it is OK. It is almost certain that it is the docker problem, not the network problem.

Solution method

Stop all containers and restart docker

Service docker restart

Content expansion

Six solutions that cannot be connected to the Internet in a Docker container

1. Use the-net:host option

two。 Use the-dns option

3. Change to dns server

4. No need for dnsmasq

5. Rebuild the docker0 network

6. Modify / etc/hosts directly in docker

This is the end of the article on "how to solve the problem that docker containers cannot ping the public network". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report