Howto – Install Docker Engine – Community (CE) 18.09 on Raspberry Pi

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 /etc/systemd/system/docker.service.d 

$ 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:

# /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd  --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:

Reference: https://docs.docker.com/engine/security/https

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.

Published by

Ronny Van den Broeck

I'm a network and system engineer for more than 20 years now. During this period I became a pro in hunting down one's and zero's, with an eager mindset to help people accomplish the same or abstract them away from the matrix.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s