我意识到这个问题已经在这里讨论过:Docker build "Could not resolve 'archive.ubuntu.com'" apt-get fails to install anything
我尝试构建一个使用ubuntu:16.04的docker镜像并尝试运行apt-get update但它会抛出此错误
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
我在上面的链接中尝试了解决方案,但似乎仍未解决我的问题。我创建了daemon.json,其中包含相应的DNS地址,并将其放在/ etc / docker /中,如上所述并重新启动了docker但仍未解决我的问题。我尝试了另一个接受的答案,我们将DNS地址添加到/ etc / default / docker,但这也没有用。如果它有帮助,我通过大学网络使用互联网。
这个问题还有其他解决办法吗?
答案 0 :(得分:0)
sudo systemctl mask systemd-resolved
rm -f /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf