If you ever wanted to experiment with docker app containers on the Raspberry Pi, look no further. This article will guide you to prepare your Raspberry Pi and install docker on top of it.
Downloading your Raspberry Pi Image
For this guide we will be using the official Raspberry Pi – Raspbian Buster Lite image which can be downloaded from the following location: https://www.raspberrypi.org/downloads/raspbian/
So download the zipped image, unzip it, and write it to your SD card with W32diskImager.
(Note: create an empty file called ssh in the root of the boot volume to activate ssh)
Installing pre-requisites and getting to the latest version
First of all, we will be updating our Raspberry Pi to the latest version. To accomplish this, login to your raspberry pi with username pi and password raspberry
Update your apt package cache:
$ sudo apt update
Upgrade your distribution to the latest version:
$ sudo apt dist-upgrade
After performing a dist-upgrade, first reboot your Raspberry Pi before continuing, otherwise you will get in trouble when installing docker.
Install some pre-requisite packages:
$ sudo apt-get install apt-transport-https ca-certificates software-properties-common -y
Installing docker onto your Pi
This is fairly easy as docker provides an installation script on their website. We just need to get it and let it do it’s work.
$ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
Executing docker commands under the Pi account doesn’t work out of the box, therefore we need to add our Pi user to the Docker group.
$ sudo usermod -aG docker pi
Starting from this point on we are able to run docker containers on the Raspberry Pi
$ docker container run hello-world
Optional: Enabling secure remote access to the docker daemon:
Before configuring secure remote access to your docker daemon it’s important to understand how OpenSSL, x509, and TLS work.
Create a folder at
$ sudo mkdir -p /etc/systemd/system/docker.service.d
And create a configuration file /etc/systemd/system/docker.service.d/startup_options.conf with below contents:
--tlsverify --tlscacert=ca.pem --tlscert=server-cert.pem --tlskey=server-key.pem
-H fd:// -H tcp://0.0.0.0:2376
Read up on the below reference document on how to generate the required certificates:
Reload the systemd daemon:
$ systemctl daemon reload
Restart your docker daemon:
$ systemctl restart docker
You are now able to connect with the docker client to the docker daemon by referencing the created certificates to the docker client.