Docker容器可以到达DNS,但不能解析主机 [英] Docker container can reach DNS but not resolve hosts

查看:920
本文介绍了Docker容器可以到达DNS,但不能解析主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行docker容器时遇到一个有趣的问题:蓝色的,我无法从容器内解析DNS。

I'm having an interesting problem running docker containers: out of the blue, I'm not able to resolve DNS from within the container.

这是一个破解:


  1. 没有什么是解决; apt-get,pip,一次性ping容器等。运行 docker run -it --dns = 8.8.8.8 ubuntu ping www.google.com 结果 ping:未知主机www.google.com 无论是否有 - dns 标志。

  1. Nothing is resolving; apt-get, pip, one-off ping containers, etc. Running docker run -it --dns=8.8.8.8 ubuntu ping www.google.com results in ping: unknown host www.google.com both with and without the --dns flag.

我可以从容器内外达到8.8.8.8。 docker run -it ubuntu ping 8.8.8.8 works。

I can reach 8.8.8.8 both from inside and outside the containers. docker run -it ubuntu ping 8.8.8.8 works.

我已经配置了要使用的容器通过编辑 / etc / sysconfig / docker 添加两个8.8.8.8,8.8.8.4和本地网络DNS服务器(在各种排列中) DOCKER_OPTS = - dns 8.8.8.8 --dns 8.8.8.4,并通过在容器上设置 - dns 8.8.8.8 标志在运行时。在每次更改之间运行 systemctl restart docker

I've configured the containers to use both 8.8.8.8, 8.8.8.4, and my local network DNS servers (in various permutations) both by editing /etc/sysconfig/docker to add DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.8.4" and by setting the --dns 8.8.8.8 flag on the containers at runtime. systemctl restart docker was run between each change.

ip_forward 已启用。 (请参阅此处

ip_forward is enabled. (see here)

已经完成了此处的完整重置。

I've done a full reset as specified here.

我正在运行Fedora 21,docker客户端版本1.5.0。

I'm running Fedora 21, docker client version 1.5.0.

任何想法?我完全失去了什么阻止码头工作者成功访问互联网。

Any ideas? I'm at a complete loss as to what's preventing docker from accessing the Internet successfully.

推荐答案

他们已经将问题解决了1.8 : https://github.com/docker/docker/issues/13381 干杯。

They have fixed the issue in 1.8: https://github.com/docker/docker/issues/13381 Cheers.

这篇关于Docker容器可以到达DNS,但不能解析主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆