Docker on Raspberry Pi

Photo Credit  via Flickr / Creative Commons

Photo Credit via Flickr / Creative Commons

I have an application I'm building that needs (well, "needs") to run on a Raspberry Pi.  Deploying new versions of a full-stack application to a Pi is a pain, because if you screw something up there's no out-of-band management like there is on a cloud server.  As a result, I've been trying to streamline my devops process to use Docker so I can leave the operating system alone and only change the containerized application.

Good News, Bad News

In case you hadn't noticed, running Docker on Raspberry Pi has gotten a lot easier.  In the latest Arch Linux for Raspberry Pi images, you can actually just:

pacman -S docker

...and it works.  All of the needed features are in the kernel, and the userland tools for Docker 0.10 are in the Arch Linux for ARM repositories.  While I am more comfortable in Debian-based distributions (like Ubuntu or Raspbian), Arch is good for this purpose because it's a much smaller, more barebones OS -- perfect for the underlying layer of a Docker container.

I'm having less luck, however, getting Arch Linux for Raspberry Pi to run in an emulated environment under QEMU.  I would have sworn I had it working a couple of months ago, using the Raspbian image and a kernel I got from XEC Design, but with the latest QEMU I can't seem to get it running again.

So What?

Docker is the new hotness in lightweight application containers.  Where today's mainstream virtualization emulates a separate operating system for each container, and for all practical purposes each container might as well be its own physical box, Docker's containers are more like isolated processes.  You can package up just as much environment as you need, and they can be instantiated so fast they act more like processes than like virtualized machines.

As of right now, Docker is officially only supported on a few x86_64-based Linux distributions.  But it really only relies on Linux kernel features, most of which are portable, plus userland binaries that are written in Go.  Since the Linux kernel source is fairly portable across architectures -- at least to ARM -- and Golang is officially supported on ARM, there should be no reason why it can't work.  And indeed it does... mostly.

That's Great, But... So What?

Raspberry Pi is a great platform for fooling around, but deploying anything to it is kind of a pain.  They would be nice little machines to run low-resource applications on, but for that problem.  Docker apps can be packaged up and distributed fairly neatly, assuming that you've got a base operating system that supports running them.  Now that we do, you can deploy your application without worrying about corruption of the underlying operating system and tools.  That can be a big help if your Raspberry Pi is down in the basement, plugged into a sensor, with no keyboard or mouse hooked up.  I think development for Raspberry Pi and other ARM-based devices is going to get a lot more fun.

I'll be giving a talk about this at the St. Louis Docker Meetup on Wednesday, June 4th in Clayton, MO.