AX Semantics Developer Blog
  • Home
  • Categories
  • Tags
  • Archives

Running DevPi as docker container

Contents

  • Install docker
  • Download and create the devpi container
  • Start the container after a reboot
  • Configure pip

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.

Install docker

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 docker.io package:

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 docker group.

sudo adduser `whoami` docker
# now log out and in again to "activate" the group for you.

Read more about this

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 docker ps 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.

Configure pip

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:

export PIP_INDEX_URL=http://localhost:3141/root/pypi/+simple/

Read more about this

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.

Comments
comments powered by Disqus

  • « A is for Automation
  • Markdown syntax highlighting for vim »

Published

Nov 6, 2014

Last Updated

2014-11-16 13:37:00+01:00

Category

Berichtsheft

Tags

  • automation 3
  • devpi 1
  • docker 6
  • howto 9
  • python 8
  • AX Semantics Developer Blog - Technical stuff and learnings we had while developing the AX environment
  • Powered by Pelican. Theme: Elegant by Talha Mansoor