首頁 > 運維 > Docker > docker容器無法ping外網

docker容器無法ping外網

發布: 2020-03-25 12:57:46
原創
3576 人瀏覽過

docker容器無法ping外網

今天在docker搭建redis環境的時候,發現yum拉取不到資源,上不到網,報瞭如下錯誤:

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.
登入後複製

測試wget

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
登入後複製

結果錯誤

unknown host mirrors.163.com
登入後複製

測試ping

在容器内部
ping www.baidu.com
登入後複製

結果還是失敗

ping: unknown host www.baidu.com
登入後複製

多開一個終端,進入主機(不是進入容器),進行ping命令測試發現是OK的,基本上可以確定是docker的問題了,而不是網路問題

解決方法

停止所有容器,重啟docker

service docker restart
登入後複製

更多相關教程,請關注PHP中文網docker教學欄位。

以上是docker容器無法ping外網的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
macos - 在Docker for mac中怎麼開啟Docker Remote API
來自於 1970-01-01 08:00:00
0
0
0
docker-machine regenerate-certs 問題
來自於 1970-01-01 08:00:00
0
0
0
docker安裝後出現Cannot connect to the Docker daemon.
來自於 1970-01-01 08:00:00
0
0
0
docker 安裝phpstudy
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板