Docker for Homelab Services

Running Docker containers in your homelab -- docker-compose, reverse proxies, Portainer, and essential services.

6 min read

Why Docker in a Homelab

Docker containers are the perfect fit for homelab services. They're lightweight, isolated, easy to deploy, and can be managed with version-controlled configuration files. Instead of installing software directly on your host (which leads to dependency conflicts and hard-to-reproduce setups), you run it in a container with everything it needs bundled in.

For someone coming from a Windows/VM-heavy background, Docker feels different but powerful. Think of it as a lightweight VM that shares the host kernel instead of virtualizing hardware.

Getting Started with Docker

On Linux (Ubuntu Server is my go-to for Docker hosts):

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

Add your user to the docker group to avoid using sudo:

sudo usermod -aG docker $USER

On Windows, Docker Desktop works but uses a Linux VM under the hood. For production-style homelab setups, run Docker on a Linux host or in a Linux VM.

Essential Docker commands:

docker-compose: Your Best Friend

Managing individual containers quickly becomes unwieldy. docker-compose lets you define multi-container applications in a single YAML file:

version: '3.8'
services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name: portainer
    restart: unless-stopped
    ports:
      - "9000:9000"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data

volumes:
  portainer_data:

Deploy with docker-compose up -d. Manage with docker-compose down, docker-compose restart, docker-compose logs.

Essential Homelab Services

Here are services every homelab should run:

Reverse Proxy Setup

A reverse proxy is essential for homelab organization. Instead of accessing services on different ports (homeassistant:8123, nextcloud:8080, vaultwarden:82), you route everything through domain names:

Use nginx-proxy with the jrcs/letsencrypt-nginx-proxy-companion for automatic SSL. All you need is a wildcard DNS record pointing to your server and the right Docker labels on each container.

Storage and Volumes

Docker containers are ephemeral -- when they stop, data inside them disappears. Use volumes for persistent storage:

Best practice: use bind mounts for configuration files and named volumes for database data. This makes backups straightforward -- just copy the host directories.

Networking in Docker

Docker creates a default bridge network, but for homelab services, create a custom network:

docker network create homelab

Then attach all your containers to it. Containers on the same network can reach each other by container name (DNS resolution is automatic):

docker run -d --name pihole --network homelab pihole/pihole:latest

Use host networking mode for services that need to bind to specific host ports (like VPN servers) or when you want maximum performance without NAT overhead.

Backup and Recovery