ubuntu - Ubuntu 14 机器上的 Docker Ubuntu 16 : no Internet connection

标签 ubuntu docker

我在我的机器上运行了一个 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'"
  • 重启 docker :sudo service docker restart
  • 关于ubuntu - Ubuntu 14 机器上的 Docker Ubuntu 16 : no Internet connection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43347052/

    相关文章:

    docker - 如何将主机设备挂载到 Docker 容器中?

    Dockerfile : add npm to an existing docker image

    docker - docker hub上的dockerfile和stackbrew用户有什么区别

    c++ - Gnuplot 和 std::filesystem::remove

    ruby-on-rails - Rails 收到对 SSL 协商的无效响应

    django - Nginx + uWSGI 基本配置

    docker - 让容器知道其在Docker中的暴露端口

    linux - 从左侧和右侧删除文本并将字符串保留在中间

    PostgreSQL 无法连接到服务器 : No such file or directory

    docker - 为什么 Heroku 每次都重建我的 Docker 容器?