Build a Raspberry Pi Docker Home Lab: Setup, Backups and Recovery

A practical 64-bit Raspberry Pi home-lab tutorial: prepare the host, install Docker, run a local web service and verify a backup without exposing the server to the internet.

In brief: Start with a supported 64-bit Raspberry Pi OS installation, working SSH and one small Docker Compose service. Keep its web port on localhost, reach it through an SSH tunnel and verify a backup before adding important data. A running container is the beginning of a home lab, not proof that it is recoverable.

This guide builds a deliberately small example: a static web page served by nginx. It teaches the host, container, network and data boundaries without first deploying a database, password manager or publicly reachable administration panel. The commands are proposed setup examples, not evidence that AYXWORKS tested this exact hardware configuration.

1. Prepare a clean host and an explicit scope

Use a Raspberry Pi suitable for the intended workload, a model-compatible power supply and cooling, reliable storage and a network connection. A Pi 4 or Pi 5 with a supported 64-bit OS is a sensible starting point for this small example; it does not establish capacity for every service you may add later. Follow the board’s documentation for storage and boot compatibility.

Use Raspberry Pi Imager and the official remote-access instructions to configure your own account and SSH. In this tutorial, the illustrative username is labuser and hostname is lab. Substitute your actual values. Confirm SSH works on your trusted home network before installing applications. If the .local name does not resolve, obtain the device address from your router.

Do not re-image an existing server to follow this guide. Imaging erases the selected storage. Use spare or explicitly backed-up media, and check the target device carefully. If Docker is already installed or the machine hosts services, reconcile its existing installation instead of replacing it with the commands below.

2. Verify the operating system and architecture

On the Pi, inspect the system:

cat /etc/os-release
dpkg --print-architecture
uname -m

The installation below is for a supported Debian-based 64-bit Raspberry Pi OS release. Check for arm64 from dpkg and the release’s actual Debian codename. Docker’s referenced Debian instructions list Bookworm and Trixie among supported releases at this review. A 64-bit kernel alone does not prove that the userland is 64-bit.

If you have a 32-bit installation, an unsupported release or a different distribution, stop and use its applicable official instructions. Do not substitute an arbitrary codename to make the repository accept the system.

3. Install Docker from the supported package repository

On the clean supported host, use the Docker Debian repository procedure. Review each package-manager prompt and stop on an error. The source-list command writes a Docker repository file; do not use it to overwrite an existing custom repository configuration without inspecting it first.

sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run --rm hello-world
sudo docker compose version

The expected checks are a successful hello-world message and a Compose version, not a particular version number invented by this guide. The example keeps sudo for Docker administration. As Docker documents, membership of the docker group grants root-level privileges; it is not merely a harmless convenience.

4. Create one isolated Compose project

The following block refuses to overwrite an existing ~/homelab/web directory. It creates an example page and a Compose file. The subshell’s error handling stops the block if the directory is already present or a command fails.

(
  set -eu
  test ! -e "$HOME/homelab/web"
  mkdir -p "$HOME/homelab/web/site"
  cd "$HOME/homelab/web"
  printf '%s\n' '<!doctype html><title>Home lab</title><h1>Home lab is running</h1>' > site/index.html
  cat > compose.yaml <<'YAML'
name: lab-web
services:
  web:
    image: nginx:stable-alpine
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ./site:/usr/share/nginx/html:ro
    restart: unless-stopped
    logging:
      driver: local
YAML
)

The image supplies the web server; the page lives in the host’s site directory, mounted read-only inside the container. The port binding listens only on the Pi’s loopback address. This is intentional: you have not created a website open to your LAN or the internet. The local logging driver provides bounded log rotation rather than leaving unbounded default logs unnoticed.

The image tag is a convenient starting point, not an immutable version. Record the resolved image digest after testing and pin that digest for a setup you need to reproduce. Do not assume pulling the same tag months later returns identical software.

5. Start the service and verify the actual page

Run these commands from the new project directory. Stop and investigate any failure before proceeding:

cd "$HOME/homelab/web" || exit 1
sudo docker compose config --quiet
sudo docker compose pull
sudo docker compose up -d
sudo docker compose ps
curl --fail http://127.0.0.1:8080/

Compose validation should report no configuration error, the service should be running, and curl should return the example HTML. “Running” alone does not prove the application works. A failed curl check directs you toward logs, the port binding and the mounted page before you add more software.

6. Open it from your laptop without publishing the port

On your laptop, open an SSH tunnel using the account and hostname configured earlier:

ssh -N -l labuser -L 127.0.0.1:8080:127.0.0.1:8080 lab.local

Keep that terminal open and visit http://127.0.0.1:8080/ in the laptop’s browser. The SSH command intentionally stays running without a shell. Stop it with Ctrl+C when finished. If port 8080 is already occupied on the laptop, choose another local port in the first part of the forwarding argument and use that port in the browser.

Do not add router port forwarding or expose the Docker socket for this exercise. Docker’s published-port behavior can interact with host firewall rules; a blanket assumption that a firewall makes every published container private is unsafe. Remote access from outside the home needs a separately reviewed access design, not an open administrator panel.

7. Inspect logs, storage and the tested image

cd "$HOME/homelab/web" || exit 1
sudo docker compose ps
sudo docker compose logs --tail=50 web
df -h
sudo docker image inspect nginx:stable-alpine --format '{{index .RepoDigests 0}}'

Use the Compose service logs for application failures and disk usage for host capacity. The final command prints the resolved image reference; retain it with the Compose file when choosing a tested version. Review logs before sharing them because real services can include private data.

Do not launch a large stack simply because the first page works. Add one service at a time, checking its supported CPU architecture, memory demand, persistent data, credentials, networking and recovery procedure. A container does not automatically make incompatible software run on ARM.

8. Create and verify a backup of this example

For this static example, the project directory contains the data and configuration needed to reconstruct it. With no concurrent file edits, run:

(
  set -eu
  umask 077
  mkdir -p "$HOME/backups"
  backup="$HOME/backups/lab-web-$(date +%Y%m%d-%H%M%S).tar.gz"
  test ! -e "$backup"
  tar -C "$HOME/homelab" -czf "$backup" web
  gzip -t "$backup"
  sha256sum "$backup"
  restore=$(mktemp -d "$HOME/lab-restore.XXXXXX")
  tar -xzf "$backup" -C "$restore"
  cmp "$HOME/homelab/web/site/index.html" "$restore/web/site/index.html"
  cmp "$HOME/homelab/web/compose.yaml" "$restore/web/compose.yaml"
  printf 'Backup: %s\nRestored copy: %s\n' "$backup" "$restore"
)

The archive is checked, extracted into a new temporary directory and compared with the source files. Successful cmp commands are silent; any failure stops the block. This demonstrates file-level backup recovery, not a complete disaster-recovery rehearsal of a running application. Keep the extracted copy until you have inspected it.

Copy the archive to another device or backup destination and protect it appropriately. A backup stored only on the Pi fails with the Pi’s storage. Real databases require a consistent application-supported backup or dump; copying a live database directory is not automatically a valid backup. Docker volumes also need an explicit plan, as described in the volume documentation.

9. Update deliberately and know how to stop

Before updating, retain the current Compose file, tested image reference and data backup. Review release notes, pull the intended image, recreate the service and repeat the page check. For applications with schema migrations, reverting the image alone may not undo the data changes; follow their documented recovery process.

To stop this example and remove its Compose containers and network:

cd "$HOME/homelab/web" || exit 1
sudo docker compose down

This does not delete the bind-mounted site directory. Do not add -v casually to other projects, and do not run volume-pruning commands as a substitute for understanding where data lives. Recreate this example with its retained Compose file and up -d when needed.

What to add only after the basics work

Authentication, TLS, off-device backups, service monitoring and an update policy matter before a home lab holds irreplaceable information. Add those according to the actual application. Keep secrets out of source control and limit who can administer Docker or SSH.

The first milestone is modest: explain where the page is stored, how it is reached, which image runs it, what survives container removal and how the backup was checked. That understanding is more valuable than a dashboard full of services whose recovery nobody has tried.

Sources and validation boundary

The linked Raspberry Pi and Docker documentation was reviewed on 14 October 2026. Hardware capacity, image availability and installation compatibility must still be checked for the selected host. This article replaces unsupported first-person build claims with an explicit tutorial; it does not claim a completed AYXWORKS hardware deployment or a measured reliability improvement.