Installing Docker on RaspberryPi
This tutorial describes useful things if you want to set up and run Docker on your RaspberryPi from scratch. If you prefer a ready to use image you may want to read this article and take the image provided by the Hypriot team. As always some people feel better if they can do the set up by themselves and don’t need to trust other people’s images. If you belong to this particular group you may want to continue reading.
1.Before you start
You will need a Raspberry Pi running Raspbian. I’ve taken the stand alone image (and not NOOBS), since I wanted to use the Raspberry Pi headless.
2.Make a raspbian server from a default raspbian image
The official Raspbian comes with a lot of packages pre-installed, many of them don’t make sense if you want to run the Raspberry Pi as a server (e.g. without a display attached). So I’ve decided to delete packages I’m not going to miss very much (thanks to cnxsoft).1
2
3
4
5
6
7
8
9
10
11
12
13$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep x11 | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep python | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep sound | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gnome | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep lxde | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gtk | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep desktop | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep gstreamer | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep avahi | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep dbus | sed s/install//`
$ sudo apt-get -y remove `sudo dpkg --get-selections | grep -v "deinstall" | grep freetype | sed s/install//`
$ sudo apt-get -y autoremove
$ sudo apt-get clean
3.Update to Debian 8 (Jessie)
Debian 8 for the Raspberry Pi already comes with a Docker enabled kernel, but you have to run the update on your own (there is no ready to use Debian 8 image available for download at this time.). I’ve found this tutorial very helpful for updating to Debian 8.1
2
3
4
5
6
7
8$ sudo sed -i 's/wheezy/jessie/' /etc/apt/sources.list
$ sudo sed -i 's/wheezy/jessie/' /etc/apt/sources.list.d/raspi.list
$ sudo apt-get update && sudo apt-get -y upgrade # answer 'y' to upcoming questions
$ sudo sudo apt-get -y dist-upgrade # answer 'y' to upcoming questions
$ sudo init 6
$ sudo apt-get -y autoremove
$ sudo apt-get -y purge $(dpkg -l | awk '/^rc/ { print $2 }')
$ sudo init 6
4.Build the Docker installation package (optional)
The Hypriot team has made a great job, automating the process of building a raspbian wheezy package for Docker, with Docker on ARM. Any docker enabled ARMv7 device will work as well. If you don’t have any, you may take a look at Scaleway, they offer AWS like services based on ARMv7:1
2
3
4$ git clone https://github.com/hypriot/rpi-docker-builder.git
$ cd rpi-docker-builder
$ sudo sh build.sh
$ sudo sh run-builder.sh
You will find the docker install package in ./dist/docker-hypriot_1.8.1-1_armhf.deb.
5.Install the docker installation package on your Raspberry Pi
The Hypriot team offers the installation package for download now, you don’t need to create the installation package by yourself.1
2
3
4
5$ curl -sSL http://downloads.hypriot.com/docker-hypriot_1.8.1-1_armhf.deb >/tmp/docker-hypriot_1.8.1-1_armhf.deb
$ sudo dpkg -i /tmp/docker-hypriot_1.8.1-1_armhf.deb
$ rm -f /tmp/docker-hypriot_1.8.1-1_armhf.deb
$ sudo sh -c 'usermod -aG docker $SUDO_USER'
$ sudo systemctl enable docker.service
6.See if it works
1 | $ sudo docker info |
OK, you’re done.