While evaluating docker as a new technology we could use I found a ready made image to run devpi as a docker container on your laptop. This makes it really easy to run the devpi server because you only need to run 2 commands (assuming you have docker already installed) and your devpi is in an isolated environment that does not collide with anything you have on your system. Everything is tested on Ubuntu 14.04 but should work similar on other systems.
If you already have docker installed and configured you can skip this step.
To install a fairly old docker version on Ubuntu 14.04 you need to install the
sudo apt-get install docker.io
For other systems check this link
To install the recent version of docker on Ubuntu run the following command:
curl -sSL https://get.docker.com/ubuntu/ | sudo sh
You will need this version to use the auto restart functions of docker.
Normally you need to run all docker commands as root or with sudo. If you don't like that you can add yourself to the
sudo adduser `whoami` docker # now log out and in again to "activate" the group for you.
Download and create the devpi container
To download the image run the following command:
docker pull scrapinghub/devpi
This may take a while if you haven't downloaded the ubuntu image before.
After that is done you can create the container with autorestart enabled (needs at least docker 1.2):
docker run -d --restart=always --name devpi -p 3141:3141 scrapinghub/devpi
Or without autorestart if you do not have a recent docker version or just don't want it to autostart all the time:
docker run -d --name devpi -p 3141:3141 scrapinghub/devpi
This also starts the container and it should be listening on localhost:3141. You can verify this by running
to list your running containers.
Start the container after a reboot
If you did not enable autorestart after a reboot the container will not be started. To start it run
docker start devpi
If you want to start it automatically with older docker versions you will need to use systemd, upstart or supervisord. Read more about this.
Now tell pip to use the devpi server by creating the file
~/.pip/pip.conf and putting this inside:
[global] index-url = http://localhost:3141/root/pypi/+simple/
or set the environment variable
PIP_INDEX_URL either manually or via your bashrc/zshrc/...rc:
Article based on https://github.com/scrapinghub/docker-devpi
Tell us what you think about this. Is something unclear? Do you have questions or ideas? Leave your comments below.