我试图docker-compose build
在公司代理后面使用,但是由于某些原因,插入代理设置的区域似乎都不允许它完成步骤。
我正在使用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.代理构建和撰写
除了我的.docker
任何用户帐户中都没有文件夹之外,我创建了目录和文件
nano ~/.docker/config.json
{
"proxies": {
"default": {
"httpProxy": "http://proxy.server:port",
"httpsProxy": "http://proxy.server:port",
"noProxy": "localhost,127.0.0.1"
}
}
}
2.环境代理
3. sysconfig的代理
我唯一知道过去一直存在的问题是我们的代理服务器是Basic-Auth,但无法找到如何添加它或是否有必要添加它。
您需要在Dockerfile本身中添加代理设置:
# above apt-get
ENV http_proxy http://user:[email protected]:[PORT]
ENV https_proxy http://user:[email protected]:[PORT]
# above git
# basic proxy auth if needed
RUN git config --global http.proxy http://user:[email protected]:[PORT] && \
git config --global https.proxy http://user:[email protected]:[PORT] && \
git config --global http.proxyAuthMethod 'basic' && \
git config --global https.proxyAuthMethod 'basic'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句