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

王林
Release: 2020-04-14 11:29:16
Original
2764 people have browsed it

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

Problem description:

When I was setting up the redis environment with docker today, I found that yum could not pull resources and could not access the Internet. 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.
Copy after login

Solution process:

1. Test wget

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
Copy after login

The result is an error

unknown host mirrors.163.com
Copy after login

2. Test ping

inside the container

ping www.baidu.com
Copy after login

The result still failed

ping: unknown host www.baidu.com
Copy after login

Open an additional terminal, enter the host (not the container), conduct a ping command test and find that it is OK. It can basically be determined that it is a problem with docker, not Internet problem.

Solution:

Stop all containers and restart docker.

service docker restart
Copy after login

Done!

Recommended tutorial:docker tutorial

The above is the detailed content of How to solve the problem that the docker container cannot ping the external network. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!