how to do docker-compose pip install with a proxy?

I am trying to get a docker-compose build to work. My original Dockerfile was,

FROM python:3.4.2-onbuild

And I have requirements.txt as,

  • Ssh connect error - not a valid identifier
  • How to install guard-test with docker?
  • docker private registry change from v1 to v2 while pulling an image
  • Runc Containerd Check pointing support
  • Docker do not release ports after stop and remove all container
  • Start full container in Docker?
  • Django==1.8.1
    gunicorn==19.3.0
    psycopg2==2.6
    redis==2.10.3
    

    Because it’s behind a proxy, pip install can’t reach outside without –proxy,

    Downloading/unpacking Django==1.8.1 (from -r requirements.txt (line 1))
    Cannot fetch index base URL https://pypi.python.org/simple/
    Could not find any downloads that satisfy the requirement Django==1.8.1 (from -r requirements.txt (line 1))
    

    I tried to change the Docker file to this and it’s not taking the –proxy pip option,

    FROM python:3.4.2-onbuild
    
    ENV HTTP_PROXY="http://<PROXY>"
    ENV PIP_OPTIONS="--proxy $HTTP_PROXY"
    
    ADD requirements.txt /requirements.txt
    
    RUN pip install --proxy $HTTP_PROXY --requirement /requirements.txt 
    

    But, docker-compose doesn’t seem to take the Dockerfile even when I do –no-cache.

  • Run Maven ant plugin after the .war is deployed?
  • How can my docker harddrive be bigger than the hosts?
  • Docker Container's network interface in promiscuous mode
  • Can I mount a windows network path inside docker without -v option?
  • Docker-Compose v3 & NGINX network issue
  • How to connect postgresql container to django container?
  • One Solution collect form web for “how to do docker-compose pip install with a proxy?”

    Does your change work when doing a docker build manually (not inside composer)?

    Once you know you have it working with a normal docker build, you should be able to force docker-compose to rebuild using docker-compose build.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.