【问题标题】:Docker - apt-get connection refused on Debian but works on UbuntuDocker - apt-get 连接在 Debian 上被拒绝,但在 Ubuntu 上工作
【发布时间】:2018-10-16 17:53:47
【问题描述】:

我是 docker 新手,所以请耐心等待 --

我正在尝试在 docker 映像上安装软件包。我无法在基于 Debian 的图像上找到任何地方。

C:\me\docker-images> docker run --rm -it debian:stretch
root@74414ba0234b:/# apt-get update
Err:1 http://security.debian.org/debian-security stretch/updates InRelease
  Could not connect to security.debian.org:80 (149.20.4.14). - connect (111: Connection refused) [IP: 149.20.4.14 80]
Err:2 http://deb.debian.org/debian stretch InRelease
  Could not connect to deb.debian.org:80 (149.20.4.15). - connect (111: Connection refused) [IP: 149.20.4.15 80]
Err:3 http://deb.debian.org/debian stretch-updates InRelease
  Unable to connect to deb.debian.org:http: [IP: 149.20.4.15 80]
Reading package lists... Done
W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease  Could not connect to deb.debian.org:80 (149.20.4.15). - connect (111: Connection refused) [IP: 149.20.4.15 80]
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease  Unable to connect to deb.debian.org:http: [IP: 149.20.4.15 80]
W: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/InRelease  Could not connect to security.debian.org:80 (149.20.4.14). - connect (111: Connection refused) [IP: 149.20.4.14 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

我什至无法 ping 任何东西:

root@71136f0cb68d:/# ping google.ca
PING google.ca (172.217.12.227) 56(84) bytes of data.

它在这里冻结。

但它适用于 ubuntu:

PS C:\me\docker-images> docker run --rm -it ubuntu
root@9d4717cf5a18:/# apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [80.4 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [626 kB]
Get:7 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.7 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [439 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3759 B]
Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [255 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1002 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.1 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [808 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [18.8 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [5157 B]
Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8075 B]
Fetched 25.2 MB in 9s (2642 kB/s)
Reading package lists... Done

当然他们访问不同的 URL,但我怀疑 debian 服务器在线,因为我可以通过网络访问它。

为什么我的连接受限于 Debian 而不是 Ubuntu 映像?

【问题讨论】:

  • 你能在Debian中检查/etc/resolv.conf吗
  • 我刚刚检查过,它与 Ubuntu 中的 /etc/resolv.conf 完全相同。我不能发布它,因为它是公司机密
  • 网络上有代理吗?

标签: docker connection apt-get


【解决方案1】:

我提取了相同的图像并尝试了,ping 和 apt-get update 工作正常。

请重启 docker 服务并重试。

sudo service docker restart

参考: https://odino.org/cannot-connect-to-the-internet-from-your-docker-containers/

【讨论】:

  • 其实我应该提到,我在 Windows 上。我通过 Icon 重新启动了 Docker 并得到了同样的错误。
  • 您是否尝试过 Windows 中 docker quickstart 终端中的“docker-machine restart”?
  • 是的。我认为问题与公司代理设置或其他网络相关。
  • 尝试删除镜像,重新启动docker服务,重新拉取并再次检查。
【解决方案2】:

如果您使用的是 Docker Machine,您可能想尝试运行:

docker-machine restart

【讨论】:

    猜你喜欢
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    • 2020-01-24
    • 2021-11-05
    相关资源
    最近更新 更多