我在我的机器上运行了一个 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。我怎样才能解决这个问题 ?
最佳答案
解决方案:
我在公司网络中,所以我必须按照以下步骤更改 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
关于ubuntu - Ubuntu 14 机器上的 Docker Ubuntu 16 : no Internet connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43347052/