【发布时间】:2016-06-20 16:55:23
【问题描述】:
Docker 版本 1.6.2,在 Ubuntu 15.10 上构建 7c8fca2
一个半月前,我突然注意到,当我构建一个 docker 映像时,在 Ubuntu 容器中使用 apt 和在 Fedora 容器中使用 dnf 时,我一直收到如下错误:
Err http://archive.ubuntu.com wily InRelease
Err http://archive.ubuntu.com wily-updates InRelease
Err http://archive.ubuntu.com wily-security InRelease
Err http://archive.ubuntu.com wily Release.gpg
Temporary failure resolving 'archive.ubuntu.com'
Err http://archive.ubuntu.com wily-updates Release.gpg
Temporary failure resolving 'archive.ubuntu.com'
Err http://archive.ubuntu.com wily-security Release.gpg
Temporary failure resolving 'archive.ubuntu.com'
Error: Failed to synchronize cache for repo 'fedora' from 'https://mirrors.fedoraproject.org/metalink?repo=fedora-22&arch=x86_64': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/metalink?repo=fedora-22&arch=x86_64 [Could not resolve host: mirrors.fedoraproject.org]
为了进行故障排除,我尝试启动了一个 Ubuntu 14.04 的 Vagrant 实例,它使用 apt 从 repos 中抓取了包。
通过简单的科学实验,这意味着我在 Docker 内部遇到了网络问题。我试过了:
sudo systemctl restart networking
sudo systemctl restart network-manager
无济于事。然后我尝试了:
sudo systemctl restart docker
which DID 解决了这个问题,然后我构建的图像可以很好地从 Fedora 和 Ubuntu 存储库中获取包。我发现我用不可知的启发式方法解决了一个问题并不令人满意。有人可以向我解释为什么我做了什么解决了这个问题,以及为什么这个问题首先突然开始发生,这样我就可以为它设置某种自动触发器以备将来避免这种情况再次发生?
【问题讨论】: