解決docker容器無法ping外網(wǎng)的問題
今天在docker搭建redis環(huán)境的時候,發(fā)現(xiàn)yum拉取不到資源,上不到網(wǎng),報了如下錯誤:
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命令測試發(fā)現(xiàn)是OK的,基本可以確定是docker的問題了,而不是網(wǎng)絡問題
解決方法
停止所有容器,重啟docker
service docker restart
內容擴展
Docker容器內不能聯(lián)網(wǎng)的6種解決方案
1.使用–net:host選項
2.使用–dns選項
3.改dns server
4.不用dnsmasq
5.重建docker0網(wǎng)絡
6.直接在docker內修改/etc/hosts
以上就是解決docker容器無法ping外網(wǎng)的問題的詳細內容,更多關于docker容器無法ping外網(wǎng)的資料請關注腳本之家其它相關文章!
相關文章
記 -bash: docker-compose: command not&nbs
這篇文章主要介紹了記 -bash: docker-compose: command not found 的問題解決方法,本文給大家介紹的非常詳細對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2024-01-01Docker下安裝ElasticSearch和Kibana的示例代碼
這篇文章主要介紹了Docker下安裝ElasticSearch和Kibana的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-08-08