Docker on a Raspberry Pi: Hypriot

Raspberry Pis are small, cheap and easy to come by. But what if you want to use Docker on them? Our goal was to run Docker on several Raspberry Pis and combine them to a cluster with Docker Swarm. To achieve this, we first needed to get Docker running on the Pi.

The Raspberry Pi is a low-cost mini computer which is about the size of a credit card. The goal of the Raspberry Pi Foundation is to help people of all ages to learn to code, though the Raspberry Pi has been used to achieve all sorts of things. The Pi we’re using is a Raspberry Pi 2 Model B. It features an ARM Cortex-A7 processor, 1GB of RAM, an HDMI port, 4 USB ports and an Ethernet port and costs about 35$. Raspberry Pis are not shipped with an OS, so you have to install one yourself on a micro SD card. With the processor being based on ARM architecture and not on x86, you are of course limited in your choice of operating system and applications. The most used OS is Raspbian which is based on Debian and has several packages bundled with it.

The normal version of Docker does not work with ARM hardware. So we needed some other way to get Docker running on the Pis. While researching, we quickly found Hypriot. This project is aimed at bringing the Docker experience to ARM hardware. It is run by five people in their spare time who call themselves “Docker pirates ARMed with explosive stuff”. On their site they offer an image which contains everything you need to run Docker on a Pi. It is based on Raspbian and includes a custom version of Docker already installed, which was build to run on ARM, and other useful utilities like Docker Machine. You can also download the Debian package for the custom-made Hypriot Docker to install it manually.

To get started with Hypriot on the Raspberry Pi, you first need to flash the image to a micro SD card. The Hypriot team offers some great guides for Windows, OS X and Linux that guide you through the process step by step. After you followed the guide you can login and you’re ready to go.

But wait, there’s a catch: Because the Pi runs on ARM hardware you can’t just go into Docker Hub and download any image and run it as a container on the Pi. The image also needs to be adapted to the hardware architecture. The Hypriot team offers some images in Docker Hub, including Java, Redis or MySQL. You can also find other image by searching for terms like “raspberry” or “rpi“.

So this is how you get Docker running on a Raspberry Pi using Hypriot. You are limited by the image selection, but the most used Docker images are available. Of course, you can always build your own images with Docker.

Next up we want to use Docker Swarm to turn the single Pis into a cluster.