Install Docker Engine on a Raspberry Pi

Install Docker host (runtime) on a Raspberry Pi

Overview

This installs Docker community Edition onto a Raspberry Pi

The host OS is Raspbian running on Raspberry Pi hardware (Raspberry Pi 4 4 GiB running Pi OS Lite.)

A Raspberry Pi computer is a great place to run Dock containers from. This page will go through the process.

Prepare the Raspberry Pi

As this will be a server in your environment that should be addressed on a reusable value it’ll be good practice to set a static IP and/or a hostname that is resolvable in your environment.

Make sure your Raspberry Pi is up to date and running the latest packages.

sudo apt-get update -y && sudo apt-get upgrade -y

Download and run the Docker installer script

The first command will download a script provided by Docker that will install Docker without much effort on your part. The second command executes the script and shows you a version table when completed.

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh
Alt Text
Docker has installed

Add your user to the Docker group

By default only Root can run Docker commands. You can skip this step and just prefix your Docker commands with SUDO but that’s annoying and you’ll fiund yourself forgetting. So you can add your user to the Docker group that allows it to run Docker commands with SUDO.

This uses pi as the username but change it to suit your own setup.

sudo usermod -aG docker pi

Test your Docker environment

A quick and simple test is to run the Docker Hello-World container.

docker run hello-world
Alt Text
Docker Hello World results

Install Docker Compose

Install the Docker Compose software.

sudo apt install docker-compose
Last modified July 21, 2024: update (e2ae86c)