Skip to content

proxying pip (HTTPS/SSL) #23

@hoijui

Description

@hoijui

As a reference to others (and possibly myself), i explain how it worked for me.

i run this docker (docker-proxy) like this:

sudo docker build -t docker-proxy .
./run.sh ssl

Then i copy test/detect-proxy.sh to the root directory of my own docker containers sources.

My own docker containers Dockerfile looks like this:

# Base image
FROM python:2-slim

MAINTAINER me <me@email.com>

WORKDIR /src

# We need info about available system packages
RUN apt-get update

# These are required by detect-proxy.sh
RUN apt-get install -y --no-install-recommends ca-certificates net-tools netcat

ADD ./detect-proxy.sh /src/detect-proxy.sh
RUN /src/detect-proxy.sh

# These are required by one of our python dependencies
RUN apt-get install -y gcc libreadline-dev

# Install python requirements
# ... option 1 (final solution):
ADD ./requirements.txt /src/requirements.txt
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install -r requirements.txt
# option 2 (may make sense during development):
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install numpy
RUN pip --cert /etc/ssl/certs/ca-certificates.crt install enum34

# Execute the python script
CMD ["python", "/src/my_script.py"]

This way, all downloads (at least by apt-get and pip) done while building and running the docker,
go through the proxy.
One thing that might be clear anyway, but worth to note: The proxy cache is lost whenever we shut the docker-proxy container down (with Ctrl+C).

Is there a way to prevent that? In other words, can we keep/carry over proxy cache between different runs of ./run.sh?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions