在主机上,它是多少's very fast to lookup a domain. But inside docker container, it'
慢,有时超时 .
主机是一个虚拟主机,它的DNS服务器地址是127.0.0.1(奇怪但是真实) . 所以我试图修改容器内的/etc/resolv.conf并将dns服务器设置为172.x(主机的地址) . 结果,我没有看到任何好的效果 .
我也尝试将容器的dns服务器设置为自构建的服务器(101.x),但是,查找域名的速度很慢 . 另一个奇怪的事情是ping 101.x非常快 .
我对这种现象感到困惑,有谁能解释和帮助?
1 回答
我不确定为什么在容器中解析DNS的速度很慢,但是我有一些程序可以解决Docker容器中的DNS问题 .
To verify DNS resolution issue:
Find out the DNS server used in your machine :
Run it again using DNS IP found in the above step which resolves the DNS issue:
To resolve it permanently add the following content as below to a new file:
有关Docker DNS configuration的更多信息 .
Restart the docker service and verify it again:
Check it by running the container:
希望这可以帮助 .