Djangocon: introduction to docker - Amjith Ramanujam

Tags: djangocon, django

(One of the summaries of a talk at the 2014 djangocon.eu).

Amjith Ramanujam

Why docker? Your site consists of a full stack. Django, database, apache, celery, etc. If you’re a full stack deveoper, you need to be able to look at all of them. And ideally you’d have exactly the same environment locally as on the server.

Docker calls itself “an easy, lightweight virtualized environment for portable applications”. A portable, self-sufficient container. It is a sandboxing technique that is a bit similar to BSD chroots.

It uses Linux containers, AUFS, Git-like versioning and a REST API.

What is the difference with a normal virtual machine? A VM needs:

  • Host OS

  • Hypervisor

  • Guest OS

  • Libs

  • The app

Docker needs:

  • Host

  • Libs.

  • Your app.

The libs and the app are part of a docker image. It is faster and much more lightweight. It reuses the host OS (but it is completely isolated!).

On OSX: use boot2docker plus an OSX docker client. It uses a virtualbox with linux, the docker client still runs on OSX, but talks to docker inside the virtualbox.

Some terminology: an image is a base that contains libs, binaries, environment variables, files and so. When you instantiate (“run”) it, you effectively make a copy. This is called the container. Using the container doesn’t modify the original image.

Registry: “PyPI” for docker images: https://index.docker.io/ . The registry lists repositories: you can put your own repository (typically from github) in there. A repository is a collection of images.

(He demoed it from OSX. Looked like something I want to use! Once the videos of the conference are online, you’d best just look at the video as that is much clearer than whatever I could write down.)

Some generic tips/comments:

  • You can mount folders from your host into your container.

  • You can forward ports from the container to a local port so that you can, for instance, connect to django.

  • You can link separate containers via env variables. So you can start up a mysql container and a django container and the django container will have an environment variable pointing at the right host+port.

  • Containers are very handy for running your tests with various database, for instance.

  • Look at Shipyard. A django app. You can list/monitor the containers running on a machine from a web browser! See http://shipyard-project.com/

http://reinout.vanrees.org/images/2014/django2.jpg

Station of Saales in 2007

 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):