How to make docker-compose pip install with a proxy server?

I am trying to create a docker build assembly. My original Dockerfile was,

FROM python:3.4.2-onbuild

And I have requirements .txt like,

Django==1.8.1
gunicorn==19.3.0
psycopg2==2.6
redis==2.10.3

Since it is behind the proxy server, pip install cannot go 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 changing the Docker file to this and it does not accept 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 accept the Docker file, even when I do --no-cache.

+4
source share
1 answer

Does your change work when executed docker buildmanually (not inside the composer)?

Once you know that you have a normal docker build, you can force the docker-compose command to rebuild with docker-compose build.

+2
source

Source: https://habr.com/ru/post/1589476/


All Articles