我正在尝试为elasticsearch-curator构建一个Docker镜像,
这是dockerfile:
FROM alpine:3.7 RUN adduser -S curator RUN apk add --update \ python \ python-dev \ py-pip \ build-base \ && pip install virtualenv \ && pip install elasticsearch-curator \ && rm -rf /var/cache/apk/* USER curator ENTRYPOINT [ "/usr/bin/curator"]
事情是我在代理下,所以我必须建立我的形象:
docker build --no-cache --build-arg HTTP_PROXY=http://xx.xx.xx.xx:xx -t elasticsearch-curator:5.4 .
但是当它想要获得virtualenv时,我得到:
Collecting virtualenv Retrying (Retry(total=4,connect=None,read=None,redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb8259ed350>,'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/virtualenv/ Retrying (Retry(total=3,redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb8259ed210>,'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/virtualenv/
我找到了解决插入问题的人
ENV http_proxy http://proxy-chain.xxx.com:911/ ENV https_proxy http://proxy-chain.xxx.com:912/
在Dockerfile中,但我不可能,因为我的代理仅在我的建筑物上有效,所以如果来自其他地方的另一个人想要构建图像,他将需要从Dockerfile中删除http_proxy env var.
有没有其他方法可以实现它?这似乎是一个非常常见的用例……