Djangocon: Local development with docker - Stefan Foulis

Tags: django, djangocon

(One of the summaries of a talk at the 2015 Djangocon EU conference).

Stefan Foulis did a live demo, so he first sacrified something to the demo gods by doing rm kitten1.jpg, rm kitten2.jgp :-)

What is docker? It is kind of like a virtual machine (sort of), but much more efficient. Without emulating a whole machine. The launchtime is milliseconds instead of seconds or minutes.

Some terminology:

  • Image. A read-only “template” like a snapshot of a virtual machine.

    Images can be layered. A django image can build upon a python image that builds upon a debian 8 image.

  • Container. An instantiated image. Like a running virtual machine.

  • Registry. A repository of images. See for instance https://hub.docker.com/ and search for python and django.

Instructions to docker go into a “docker file”. In it you specify a base image and further instructions like packages that need installing, directories that need to be made, the main working directory and which program to start up as the one single main program that is run inside the docker container.

With docker compose, a yaml format, you can “compose” containers. This means you can run multiple containers at the same time, for instance a postgres container running next to your django container.

Handy: there is a docker image for an nginx proxy. It automatically proxies requests to running docker containers if you have configured them with a domain name. Including ssl. Very handy for local development.

 
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):