pipdockerdevpi

How to force docker build to use devpi server for pip install command?


I am trying to build an image for my flask based web-application using docker build. My Dockerfile looks like this:

FROM beehive-webstack:latest
MAINTAINER Anuvrat Parashar <anuvrat@zopper.com>

EXPOSE 5000
ADD . /srv/beehive/

RUN pip install -i http://localhost:4040/root/pypi/+simple/ -r /srv/beehive/requirements.txt

pip install without the -i flag works, but it downloads everything from pypi which, naturally is slow.

The problem is that pip does not access the devpi server running on my laptop. How can I go about achieving that?


Solution

  • localhost refers to the docker container, not to your host as RUN lines are just executed commands in the container. You thus have to use a network reachable IP of your laptop.

    Con: This makes your Dockerfile unportable, if others don't have a pypi mirror running.