加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

python – 在代理下的dockerfile中的pip

发布时间:2020-12-16 03:30:51 所属栏目:安全 来源:网络整理
导读:我正在尝试为elasticsearch-curator构建一个Docker镜像, 这是dockerfile: FROM alpine:3.7RUN adduser -S curatorRUN apk add --update python python-dev py-pip build-base pip install virtualenv pip install elasticsearch-curator rm -

我正在尝试为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(

我找到了解决插入问题的人

ENV http_proxy http://proxy-chain.xxx.com:911/
ENV https_proxy http://proxy-chain.xxx.com:912/

在Dockerfile中,但我不可能,因为我的代理仅在我的建筑物上有效,所以如果来自其他地方的另一个人想要构建图像,他将需要从Dockerfile中删除http_proxy env var.

有没有其他方法可以实现它?这似乎是一个非常常见的用例……

最佳答案
我通过在命令行中添加HTTPS_PROXY来解决它:

docker build  --no-cache --build-arg HTTP_PROXY=http://xx.xx.xx.xx:xx --build-arg HTTPS_PROXY=http://xx.xx.xx.xx:xx -t elasticsearch-curator:5.4 .

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读