Could not resolve host in docker

早过忘川 提交于 2019-12-19 03:44:52

问题


I'm trying to do an jenkins on docker, on my machine (Ubuntu).

I have to access to the git repo, in my company. But in jenkins, I get this error :

Could not resolve host: gogs.mycompany.com

I think this is an DNS error, so I tried to launch my docker like that (with --dns and --dns-search)

sudo docker run -p 8080:8080 -p 50000:50000 -v /home/xero/jenkins:/var/jenkins_home --name=myproject-jenkins2 --dns=127.0.1.1 --dns-search=mycompany.lan jenkins

Here my /etc/resolv.conf :

nameserver 127.0.1.1

search mycompany.lan

What I'm doing wrong ?


回答1:


The DNS was wrong. (--dns=127.0.1.1)

This DNS server, is an internal DNS, Dnsmasq, it's a DNS forwarder.

So I needed to know the real internal DNS server :

nmcli dev show | grep DNS

And add the right address (10.0.1.1 in my case) :

sudo docker run -p 8080:8080 -p 50000:50000 -v /home/xero/jenkins:/var/jenkins_home --name=myproject-jenkins2 --dns=10.0.1.1 jenkins



来源:https://stackoverflow.com/questions/47177850/could-not-resolve-host-in-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!