Docker on Raspberry Pi in 4 Simple Steps

ANOTHER UPDATE: We’ve since released resin.io [https://resin.io] as a full service allowing you to easily run and update docker containers on multiple architectures. UPDATE: We’ve since released Docker 0.7.2 for ARM. Read More [https://resin.io/blog/release-docker-0-7-2-for-arm/] One week ago- we released our instructions to installing Docker on the Raspberry Pi [https://resin.io/blog/docker-on-raspberry-pi/]. The response has been fantastic with…

ANOTHER UPDATE: We’ve since released resin.io as a full service allowing you to easily run and update docker containers on multiple architectures.

UPDATE: We’ve since released Docker 0.7.2 for ARM. Read More

One week ago, we released our instructions to installing Docker on the Raspberry Pi. The response has been fantastic with a lot of excitement but also some feedback that the installation process was far too complicated. The general sentiment was along the lines of “Why not just provide a disk image?”

We looked into our options in response to that feedback, and whilst we decided against providing an entire disk image for two reasons: First, a user with an existing Arch installation would have to wipe it, and second, we would have to repeat the process every time Arch or Docker releases a new image. Instead, we prebuilt and packaged the key components, cutting down the ~100 steps to just four.

Step 3 below is basically a single line installation. What does that single line do? It downloads and installs a set of packages we’ve released via Github. Nothing more, nothing less.

Simplified Instructions:

  1. Insert an SD Card into your system and install Arch Linux on it.
  2. Boot your Raspberry Pi, find its IP address and SSH in as user root with password root.
  3. Run the following command:
    bash
    curl https://raw.githubusercontent.com/resin-io/docker-install-script/master/install.sh | sh
  4. Restart your Raspberry Pi and enjoy using Docker on it.

Using Docker on the Raspberry Pi

Once you’ve got Docker installed, you’ll probably want to do something more than rest on your laurels and enjoy your accomplishment. Doing anything further involves installing a base image. We’ve released resin/rpi-raspbian. From this you can start to work with Docker on your Raspberry Pi:

  1. Start the docker daemon:
    bash
    docker -d &
  2. Enable IPv4 forwarding
    bash
    sysctl -w net.ipv4.ip_forward=1
  3. Download the base image and start a shell:
    bash
    docker run -t -i resin/rpi-raspbian /bin/bash

Getting an example project working inside docker

We created an example project which is Google’s Coder Project packaged in a docker container. To run it, logout from the raspbian shell from the previous step and simply do:

bash
docker run -d -p 8081:8081 resin/rpi-google-coder

Once that’s complete, you should be able to access Google Coder at https://<rpi ip address here>:8081 on your computer and start hacking. Don’t forget to use HTTPS as Coder will hang with simple HTTP.

How to get Dockerfiles working on the Raspberry Pi

We’ve published the Raspbian base image to help you get started. As most Dockerfiles are based on the Ubuntu base image and Raspbian is very similar to Ubuntu, it’s likely they will work by just changing the FROM ubuntu command to FROM resin/rpi-raspbian and then building it. If it does not work, it will be something specific to the Dockerfile you’re working with. Hopefully you’ll be able to overcome it and produce a Raspberry Pi image.

Since images compiled for x86-64 will not work on the Raspberry Pi and vice versa, we ask that if you create new images that will work for on the RPi, you prefix them with rpi-\* so that everyone else can discover them. Hopefully the Docker team will provide some native support for different architectures, but for the moment this should be good enough.

What’s next

We’re proud to have delivered an easy way to get Docker working on your Raspberry Pi. We are convinced the potential for Docker in the embedded world is as large or larger than its potential in the cloud. We hope to see more images for the Pi showing up in the Docker index.

Having completed this milestone, the Resin.io team will shift its focus to preparing Resin.io: The Product for an alpha release in early December, just in time for your Christmas projects. We’ll also start writing more about resin.io and the thinking behind it, which should answer the prominent question of “yeah, but what is Resin.io?”.

We’d love to hear what you think about the direction we’re heading in and potential uses for our product.

Any questions? or you’d just like to say hi, come find us on our community chat.


Posted

in

Tags: