Skip to main content

Command Palette

Search for a command to run...

Install Docker and Docker Compose on a Raspberry Pi

Updated
View as Markdown
Install Docker and Docker Compose on a Raspberry Pi

Docker lets you run containerized services on a Raspberry Pi with clean isolation and easy updates, and Docker Compose lets you define and manage those services declaratively via a YAML file instead of long docker run commands. This tutorial covers installing both on Raspberry Pi OS, as a base setup for running containerized services such as Pi-hole, Home Assistant, or anything else you want to containerize on the Pi.

Prerequisites

  • A Raspberry Pi (any model with a 64-bit OS works best; Docker also runs on 32-bit but with a smaller selection of images)

  • Raspberry Pi OS, recent version, already flashed and booted

  • SSH or local terminal access with sudo privileges

  • An active internet connection

How this works

Docker on Raspberry Pi OS is installed the same way as on any Debian-based system, via the official get.docker.com convenience script, which detects the Pi's ARM architecture and installs the correct packages automatically. Docker Compose used to be a separate Python tool (docker-compose, with a hyphen); today it ships as a Docker plugin (docker compose, no hyphen, invoked as a subcommand), and the official install script already includes it — no separate installation step needed.

After installing Docker, the Docker daemon (docker.service) is registered with systemd and set to start automatically on boot — this is what makes any container with a restart policy come back up automatically every time the Pi powers on, without any extra configuration.

Steps

1. Update the system

sudo apt update && sudo apt full-upgrade -y

Keeps the base system current before installing anything new.

2. Install Docker

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

Callout — Verify the install script first Piping curl | sh is convenient but means trusting the script sight unseen. If you'd rather review it, download it first (curl -fsSL https://get.docker.com -o get-docker.sh), inspect it in vim, then run sh get-docker.sh.

This installs the Docker Engine along with the docker compose plugin, buildx, and the container runtime — everything needed to build and run containers on the Pi.

3. Allow your user to run Docker without sudo

sudo usermod -aG docker $USER

Log out and back in (or run newgrp docker) for the new group membership to take effect.

4. Verify the installation

docker --version
docker compose version

Both commands should print a version number. If either fails, the corresponding package didn't install correctly — see Troubleshooting below.

5. Confirm Docker starts automatically

sudo systemctl is-enabled docker

This should return enabled, confirming Docker will start on every boot without manual intervention. If it doesn't:

sudo systemctl enable docker

Summary

We installed Docker and the Docker Compose plugin on a Raspberry Pi using the official install script, added the current user to the docker group, and confirmed the daemon is set to start automatically on boot. With this in place, the Pi is ready to run containerized services that come back up on their own after every power cycle.