Docker 在 Windows 10 代理传播到容器不起作用 [英] Docker at Windows 10 proxy propagation to containers not working
问题描述
我支持合作代理并在 Windows 10 上运行 docker.我已根据
我可以提取图像,但这些代理设置不会传播到容器,例如当我运行 alpine env 时,它不显示代理配置.以下是我的输出
λ docker run alpine envPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin主机名=14fca5bee12f家=/根
以下是文档中的预期输出.
在构建以下 docker 文件时,我从 alpine 容器中收到连接错误
Docker 版本
Docker 版本 17.12.0-ce,构建 c97c6d6
DockerFile
FROM alpine:latest添加 HelloWorld.class HelloWorld.class运行 apk --update 添加 openjdk8-jre入口点 ["java", "-Djava.security.egd=file:/dev/./urandom", "HelloWorld"]
错误
第 3/4 步:运行 apk --update add openjdk8-jre--->运行在 1205b24d5044获取 http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz错误:http://dl-cdn.alpinelinux.org/alpine/v3.7/main:无法连接到服务器(检查存储库文件)警告:忽略 APKINDEX.70c88391.tar.gz:没有这样的文件或目录获取 http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz错误:http://dl-cdn.alpinelinux.org/alpine/v3.7/community:无法连接到服务器(检查存储库文件)警告:忽略 APKINDEX.5022a8a2.tar.gz:没有这样的文件或目录错误:不可满足的约束:openjdk8-jre(缺失):要求:世界[openjdk8-jre]命令 '/bin/sh -c apk --update add openjdk8-jre' 返回一个非零代码:1
将代理作为构建参数传递
我尝试了以下命令,它成功了.是否有任何其他方法可以自动传播文档中提到的代理设置(请参阅上面的链接)
docker build --tag "docker-hello-world:latest" .--build-arg http_proxy=http://<用户名>:<密码>@proxy_address:proxy_port/--build-arg https_proxy=http://<用户名>:<密码>@proxy_address:proxy_port/--build-arg no_proxy=localhost,127.0.0.1
我也遇到了同样的问题.拉取图像正常,但配置容器不起作用.在这种情况下,解决方案是为 Docker 提供一个名为 ~/.docker/config.json
的配置文件,其内容如下.
<代码>{代理":{默认":{"httpProxy": "http://proxy.server....com:8080",httpsProxy":https://proxy.server.....com:8080"}}}
我希望这能解决您的问题.
I am behind cooperate proxy and running docker on windows 10. I have setup the proxy on docker as per the documentation here.
I am able to pull images but these proxy settings are not propagating to containers e.g. when I run alpine env, it does not show proxy conf. Below is my output
λ docker run alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=14fca5bee12f
HOME=/root
Following is the expected output as per the documentation.
On building following docker file, I get connection errors from alpine container
Docker Version
Docker version 17.12.0-ce, build c97c6d6
DockerFile
FROM alpine:latest
ADD HelloWorld.class HelloWorld.class
RUN apk --update add openjdk8-jre
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "HelloWorld"]
Error
Step 3/4 : RUN apk --update add openjdk8-jre
---> Running in 1205b24d5044
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/main: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.7/community: could not connect to server (check repositories file)
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
openjdk8-jre (missing):
required by: world[openjdk8-jre]
The command '/bin/sh -c apk --update add openjdk8-jre' returned a non-zero code: 1
Passing Proxy as build-arg
I tried the following command and it worked. Is there any other way to automatically propagate the proxy settings as mentioned in documentation (see link above)
docker build --tag "docker-hello-world:latest" . --build-arg http_proxy=http://<username>:<password>@proxy_address:proxy_port/ --build-arg https_proxy=http://<username>:<password>@proxy_address:proxy_port/ --build-arg no_proxy=localhost,127.0.0.1
I had the same problem. Pulling images was working but provisioning a container was not working. In this case the solution was to provide Docker with a configuration file named ~/.docker/config.json
with the following contents.
{
"proxies":
{
"default":
{
"httpProxy": "http://proxy.server....com:8080",
"httpsProxy": "https://proxy.server.....com:8080"
}
}
}
I hope this will solve your problem.
这篇关于Docker 在 Windows 10 代理传播到容器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!