Pip inside dockerfile under proxy : <p>I am trying to build a Docker image for elasticsearch-curator, </p>

<p>Here is the dockerfile:</p>

<pre><code>FROM alpine:3.7

RUN adduser -S curator

RUN apk add --update \
    python \
    python-dev \
    py-pip \
    build-base \
  &amp;&amp; pip install virtualenv \
  &amp;&amp; pip install elasticsearch-curator \
  &amp;&amp; rm -rf /var/cache/apk/*

USER curator

ENTRYPOINT [ "/usr/bin/curator"]
</code></pre>

<p>Thing is I am under a proxy, so I must build my image with:</p>

<pre><code>docker build  --no-cache --build-arg HTTP_PROXY=http://xx.xx.xx.xx:xx -t elasticsearch-curator:5.4 .
</code></pre>

<p>But when it wants to get virtualenv, I get:</p>

<pre><code>Collecting virtualenv
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb8259ed350&gt;, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/virtualenv/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(&lt;pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb8259ed210&gt;, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/virtualenv/
</code></pre>

<p>I found people solving issue inserting </p>

<pre><code>ENV http_proxy http://proxy-chain.xxx.com:911/
ENV https_proxy http://proxy-chain.xxx.com:912/
</code></pre>

<p>in the Dockerfile, but it is not possible for me, because my proxy is only valid on my building, so if another person from another place want to build the image, he will need to remove http_proxy env var from Dockerfile.</p>

<p>Is there any other way to achieve it? It seems like a very common use case...</p>
