我在我的机器上运行了一个Ubuntu docker但是当我输入apt-get update
命令时,它说:
root@50e964833537:/# apt-get update
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
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-security/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
我尝试了几个“解决方案”但我发现它仍无效。 我无法访问docker中的任何命令,因为我无法更新。我想因为我的Docker无法访问Internet。我该如何解决这个问题?
答案 0 :(得分:1)
解决方案:
我在公司网络中,因此我必须按照以下步骤更改DNS IP地址:
在主机上:
nm-tool | grep DNS
它将输出DNS服务器sudo nano /etc/default/docker
并使用您在第一步中获得的DNS更改以下行:
DOCKER_OPTS="--dns 'your_dns_server_1' --dns 'your_dns_server_2'"
sudo service docker restart
答案 1 :(得分:0)
对我而言,我们的内部VPN导致了这个问题。你应该尝试将其关闭一次以确定。
在这种情况下,This解决方案适合您。
pkill docker; iptables -t nat -F; ifconfig docker0 down; brctl delbr docker0