无法 docker-从代理后面撰写
Cannot docker-compose from behind a proxy
我正在尝试在公司代理后面使用 docker-compose build
,但出于某种原因,none 您插入代理设置的区域似乎允许它完成这些步骤。
我使用的是 CentOS 8 服务器。
错误信息:
[root@centos8server docker]# docker-compose build
postgres uses an image, skipping
start_dependencies uses an image, skipping
Building custom-docker
Step 1/15 : FROM swift:5.2.3 as builder
---> 67a9c8f156c1
Step 2/15 : ARG env
---> Using cache
---> b767ab90fbe8
Step 3/15 : RUN apt-get -qq update && apt-get install -y libssl-dev zlib1g-dev && rm -r /var/lib/apt/lists/*
---> Running in b935c12d0bbd
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libssl-dev
ERROR: Service 'custom-docker' failed to build: The command '/bin/sh -c apt-get -qq update && apt-get install -y libssl-dev zlib1g-dev && rm -r /var/lib/apt/lists/*' returned a non-zero code: 100
我最初的想法是 CentOS 服务器使用的 apt
和 apt-get
并不存在,但我随后在家中构建了没有代理限制的服务器,它就可以正常工作。我可以 wget
地址并且没有问题。
我尝试在以下方面添加代理:
1. proxy for build and compose
除了我在任何用户帐户中都没有 .docker
文件夹,所以我创建了目录和文件
nano ~/.docker/config.json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.server:port",
"httpsProxy": "http://proxy.server:port",
"noProxy": "localhost,127.0.0.1"
}
}
}
2。 Proxy for environment
3。 Proxy for sysconfig
我唯一知道的是过去一直存在的问题是我们的代理是 Basic-Auth 但一直无法找到如何添加它或是否有必要添加。
您需要在 Dockerfile 本身中添加代理设置:
# above apt-get
ENV http_proxy http://user:password@proxy.domain.ltd:[PORT]
ENV https_proxy http://user:password@proxy.domain.ltd:[PORT]
# above git
# basic proxy auth if needed
RUN git config --global http.proxy http://user:password@proxy.domain.ltd:[PORT] && \
git config --global https.proxy http://user:password@proxy.domain.ltd:[PORT] && \
git config --global http.proxyAuthMethod 'basic' && \
git config --global https.proxyAuthMethod 'basic'
我正在尝试在公司代理后面使用 docker-compose build
,但出于某种原因,none 您插入代理设置的区域似乎允许它完成这些步骤。
我使用的是 CentOS 8 服务器。
错误信息:
[root@centos8server docker]# docker-compose build
postgres uses an image, skipping
start_dependencies uses an image, skipping
Building custom-docker
Step 1/15 : FROM swift:5.2.3 as builder
---> 67a9c8f156c1
Step 2/15 : ARG env
---> Using cache
---> b767ab90fbe8
Step 3/15 : RUN apt-get -qq update && apt-get install -y libssl-dev zlib1g-dev && rm -r /var/lib/apt/lists/*
---> Running in b935c12d0bbd
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libssl-dev
ERROR: Service 'custom-docker' failed to build: The command '/bin/sh -c apt-get -qq update && apt-get install -y libssl-dev zlib1g-dev && rm -r /var/lib/apt/lists/*' returned a non-zero code: 100
我最初的想法是 CentOS 服务器使用的 apt
和 apt-get
并不存在,但我随后在家中构建了没有代理限制的服务器,它就可以正常工作。我可以 wget
地址并且没有问题。
我尝试在以下方面添加代理:
1. proxy for build and compose
除了我在任何用户帐户中都没有 .docker
文件夹,所以我创建了目录和文件
nano ~/.docker/config.json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.server:port",
"httpsProxy": "http://proxy.server:port",
"noProxy": "localhost,127.0.0.1"
}
}
}
2。 Proxy for environment
3。 Proxy for sysconfig
我唯一知道的是过去一直存在的问题是我们的代理是 Basic-Auth 但一直无法找到如何添加它或是否有必要添加。
您需要在 Dockerfile 本身中添加代理设置:
# above apt-get
ENV http_proxy http://user:password@proxy.domain.ltd:[PORT]
ENV https_proxy http://user:password@proxy.domain.ltd:[PORT]
# above git
# basic proxy auth if needed
RUN git config --global http.proxy http://user:password@proxy.domain.ltd:[PORT] && \
git config --global https.proxy http://user:password@proxy.domain.ltd:[PORT] && \
git config --global http.proxyAuthMethod 'basic' && \
git config --global https.proxyAuthMethod 'basic'