解決docker容器無(wú)法ping外網(wǎng)的問(wèn)題
今天在docker搭建redis環(huán)境的時(shí)候,發(fā)現(xiàn)yum拉取不到資源,上不到網(wǎng),報(bào)了如下錯(cuò)誤:
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.
測(cè)試wget
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
結(jié)果報(bào)錯(cuò)
unknown host mirrors.163.com
測(cè)試ping
在容器內(nèi)部
ping www.baidu.com
結(jié)果還是失敗
ping: unknown host www.baidu.com
多開一個(gè)終端,進(jìn)入主機(jī)(不是進(jìn)入容器),進(jìn)行ping命令測(cè)試發(fā)現(xiàn)是OK的,基本可以確定是docker的問(wèn)題了,而不是網(wǎng)絡(luò)問(wèn)題
解決方法
停止所有容器,重啟docker
service docker restart
內(nèi)容擴(kuò)展
Docker容器內(nèi)不能聯(lián)網(wǎng)的6種解決方案
1.使用–net:host選項(xiàng)
2.使用–dns選項(xiàng)
3.改dns server
4.不用dnsmasq
5.重建docker0網(wǎng)絡(luò)
6.直接在docker內(nèi)修改/etc/hosts
以上就是解決docker容器無(wú)法ping外網(wǎng)的問(wèn)題的詳細(xì)內(nèi)容,更多關(guān)于docker容器無(wú)法ping外網(wǎng)的資料請(qǐng)關(guān)注本站其它相關(guān)文章!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信