Docker-apt-get连接在Debian上被拒绝,但在Ubuntu上工作



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

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

C:medocker-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:medocker-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 镜像上不受限制?

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

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

sudo service docker restart

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

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

docker-machine restart

相关内容

最新更新