Connect devpi to your docker container

You’re running pip install, buildout or your automated tests within a docker container and after running it multiple times you’ve become tired of waiting for it to finally complete? Then it’s time to connect a devpi server.



If you’re running a Mac, please prepare a docker-machine first, please use docker-machine installation guide.

$ docker-machine create -d virtualbox dev
$ docker-machine start dev
$ eval $(docker-machine env dev)

Test your docker-machine by running docker ps command.

You’ll need a working directory where docker-compose.yml file and certificates are stored in, so please create a folder my-devpi as shown below:

$ mkdir -p $HOME/my-devpi/cache     # store your devpi data
$ cd $HOME/my-devpi

devpi docker-compose file

I found a devpi docker image which covers exactly what I was looking for. I really like docker-compose to build services. So I tried to use it for my devpi server as well. Please touch a file called docker-compose.yml in current directory:

$ touch docker-compose.yml

and fill in following content:

  container_name: devpi
  restart: always
  image: sigma/devpi
    - 3141:3141
    - ./data:/mnt

Of course this is overkill here, but I started to use docker-compose for every service so I don’t have to carry a docker reference card with me.

Starting devpi docker-container

Now you’re ready to run docker-compose up to start your devpi server. Attaching -d will send it to background:

$ docker-compose up -d

Check your container is running:

$ docker ps
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                    NAMES
24ad92999069        sigma/devpi          "/"                8 seconds ago       Up 7 seconds>3141/tcp   devpi

Adding systemd startup script (optional)

If you’re running an operating system which supports systemd you can use following example to start your devpi server with systemd:

Description=devpi docker-container

ExecStart=/usr/local/bin/docker-compose -f ~/my-devpi/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f ~/my-devpi/docker-compose.yml stop
ExecStopPost=/usr/local/bin/docker-compose -f ~/my-devpi/docker-compose.yml rm -f


Connecting your devpi server

If your devpi server is up and running you’re ready to link this container to your test container and set your index server within your buildout, pip or setuptools configuration files:

$ docker run --link devpi -it ubuntu:14.04

Configuration files are located in:

  • pip configuration in ~/.pip/pip.conf:

    index-url = http://devpi:3141/root/pypi/+simple/
  • setuptools located in ~/.pydistutils.cfg:

    index_url = http://devpi:3141/root/pypi/+simple/
  • buildout globally in ~/.buildout/default.cfg or locally in buildout.cfg:

    index = http://devpi:3141/root/pypi/+simple/


comments powered by Disqus