我试图在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)
我用Google搜索,与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
我的解决方案是在我的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'
解决方案:Fix Docker's networking DNS config
其他论坛
我在forums.docker.com
找到了一个讨论主题,但却没有
找到解决方案
https://forums.docker.com/t/cannot-run-apt-get-update-successfully-behind-proxy-beta-13-1/14170
使用正确的代理设置语法进行更新以解决问题!
感谢Matt的回答。我意识到了语法 我用的是错的。他们不能
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
就开始工作了。非常感谢!
答案 0 :(得分:2)
您的代理设置似乎无效。运行以下命令会生成相同的错误消息:
docker run -ti --rm \
-e https_proxy=http://8000:80 \
-e http_proxy=http://8000:80 \
debian apt-get update
您需要一个可以作为代理连接的有效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
您应该能够从代理地址
获得某种形式的回复→ 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
<
答案 1 :(得分:0)
我在Mac OSX上也遇到了这个问题。我尝试了@ Matt的解决方案。我使用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)
。
我使用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
。它有效。