Da-Yuan Tung
Da-Yuan Tung

Reputation: 51

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,

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.

Upvotes: 5

Views: 5817

Answers (1)

programmerq
programmerq

Reputation: 6534

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.

Upvotes: 2

Related Questions