Docker - 在Debian上拒绝apt-get连接但在Ubuntu上运行

时间:2018-05-16 15:06:54

标签: docker connection apt-get

我是一个码头新手,所以忍受我 -

我试图在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

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

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

2 个答案:

答案 0 :(得分:1)

我拉了相同的图片并尝试了,pingapt-get update工作正常。

请重新启动docker服务,然后重试。

sudo service docker restart

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

答案 1 :(得分:0)

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

docker-machine restart