无法启动连接到8000:80(…) – 连接(22:无效的参数)

我正试图在Docker容器中运行apt-get update

我得到这些错误:

 W: Failed to fetch http://ftp.osuosl.org/pub/mariadb/repo/10.2/debian/dists/jessie/Release.gpg Cannot initiate the connection to 8000:80 (0.0.31.64). - connect (22: Invalid argument) W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg Cannot initiate the connection to 8000:80 (0.0.31.64). - connect (22: Invalid argument) 

我search了一下,与docker apt-get有关的一些问题与代理设置DNS设置有关 。 我想我已经解决了这两个问题,但我仍然得到上述错误。 有任何想法吗?

代理设置

错误信息会是这个 – 我不再看到这些错误。

 W: Failed to fetch http://ftp.osuosl.org/pub/mariadb/repo/10.2/debian/dists/jessie/Release.gpg Cannot initiate the connection to ftp.osuosl.org:80 (2600:3404:200:237::2). - connect (101: Network is unreachable) [IP: 2600:3404:200:237::2 80] W: Failed to fetch https://repo.percona.com/apt/dists/jessie/main/binary-amd64/Packages Connection timed out after 120001 milliseconds 

我的解决scheme已经在我的dockerfile中放入这样的行。 从那时起,错误信息已经改变,所以我相信这是代理问题的正确解决办法。

 ENV http_proxy <myCorpProxy>:8000 ENV https_proxy <myCorpProxy>:8000 

DNS设置

错误将是这个 – 我不再看到这些错误。

 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Could not resolve 'my.proxy.net' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Could not resolve 'my.proxy.net' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Could not resolve 'my.proxy.net' 

解决scheme: 修复Docker的networkingDNSconfiguration

其他论坛

我在forums.docker.com上find了一个讨论主题,但还没有find解决scheme

https://forums.docker.com/t/cannot-run-apt-get-update-successfully-behind-proxy-beta-13-1/14170

用正确的代理设置语法更新解决问题!

感谢马特的回答。 我意识到我使用的语法是错误的。 他们不能

 ENV http_proxy <myCorpProxy.domain.name>:8000 ENV https_proxy <myCorpProxy.domain.name>:8000 

但必须是

 ENV http_proxy http://<myCorpProxy.domain.name>:8000 ENV https_proxy http://<myCorpProxy.domain.name>:8000 

一旦我改变了,我的apt-get就开始工作了。 非常感谢!

它看起来像你的代理设置是无效的。 运行以下命令会产生相同的错误消息:

 docker run -ti --rm \ -e https_proxy=http://8000:80 \ -e http_proxy=http://8000:80 \ debian apt-get update 

您需要一个有效的http://hostname:port ,您可以将其作为代理连接到该http://hostname:port

 docker run -ti --rm \ -e https_proxy=http://10.8.8.8:3142 \ -e http_proxy=http://10.8.8.8:3142 \ debian apt-get update 

您应该能够从代理地址获得某种forms的响应

 → curl -v http://10.8.8.8:3142 * Rebuilt URL to: http://10.8.8.8:3142/ * Trying 10.8.8.8... * Connected to 10.8.8.8 (10.8.8.8) port 3142 (#0) > GET / HTTP/1.1 > Host: 10.8.8.8:3142 > User-Agent: curl/7.43.0 > Accept: */* > < HTTP/1.1 406 Usage Information < Connection: close < Transfer-Encoding: chunked < Content-Type: text/html < 

我也在Mac OSX上遇到了这个问题。 我尝试了@ Matt的解决scheme。 我用docker run -it -e http_proxy=http://127.0.0.1:1235 -e https_proxy=http://127.0.0.1:1235 ubuntu来设置代理。 我得到了Could not connect to 127.0.0.1:1235 (127.0.0.1). - connect (111: Connection refused) Could not connect to 127.0.0.1:1235 (127.0.0.1). - connect (111: Connection refused)

我使用docker inspect <container_id>来获取该docker inspect <container_id>的代理信息。 我有"HTTP_PROXY=docker.for.mac.localhost:1235", "HTTPS_PROXY=docker.for.mac.localhost:1235" 。 我将命令更改为docker run -it -e http_proxy=http://docker.for.mac.localhost:1235 -e https_proxy=http://docker.for.mac.localhost:1235 ubuntu 。 有用。