Why Containers Simplified Self-Hosting

Containers

Before containers, installing web apps directly onto a Linux host meant juggling conflicting Python, PHP, and Node versions where upgrading one tool could break another. Containers package an application and its libraries into an isolated runtime while sharing the host Linux kernel.

For home servers, that means running 15 or 20 independent services on a single host without dependency conflicts.

Docker vs Podman

FeatureDockerPodman
DaemonRuns background dockerd (root by default)Daemonless architecture
Rootless executionSupported with extra setupNative rootless default
Compose toolingdocker compose (v2)podman-compose or Compose socket
Community docsVast upstream Compose examplesGrowing, CLI-compatible with Docker
Systemd integrationBasic restart policiesNative Quadlet and unit generation

For most self-hosters: Docker remains the path of least resistance because nearly every open-source app publishes an official compose.yml snippet tested against Docker Engine.

Choose Podman if: You prefer rootless containers by default or manage RHEL-family systems such as Fedora, AlmaLinux, or Rocky Linux.

Docker Fundamentals

Images, Containers, and Volumes

  • Image: A read-only template pulled from Docker Hub or GitHub Container Registry (ghcr.io).
  • Container: A running instance created from an image.
  • Volume: Persistent host storage mounted into a container so data survives restarts and image upgrades.

Essential Commands

# Pull an image
docker pull nextcloud:latest

# Run a container
docker run -d --name myservice -p 8080:80 -v data:/app/data nextcloud:latest

# List running containers
docker ps

# Stop / Start / Restart
docker stop myservice
docker start myservice
docker restart myservice

# View logs
docker logs myservice
docker logs -f myservice  # Follow in real-time

# Enter a running container
docker exec -it myservice bash

# Remove a container (preserves volumes)
docker rm myservice

# Remove unused images
docker image prune

Docker Compose: The Standard Home Stack Format

Docker Compose describes multi-container stacks in one declarative compose.yml file rather than long shell commands.

Example: Home Lab Stack

services:
  # Reverse Proxy
  caddy:
    image: caddy:2-alpine
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    restart: unless-stopped

  # File Sync
  nextcloud:
    image: nextcloud:latest
    volumes:
      - nc_data:/var/www/html
    environment:
      - POSTGRES_HOST=nc_db
      - POSTGRES_DB=nextcloud
    depends_on:
      - nc_db
    restart: unless-stopped

  nc_db:
    image: postgres:16-alpine
    volumes:
      - nc_db_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=nextcloud
    restart: unless-stopped

  # Password Manager
  vaultwarden:
    image: vaultwarden/server:latest
    volumes:
      - vw_data:/data
    restart: unless-stopped

  # Media Server
  jellyfin:
    image: jellyfin/jellyfin:latest
    volumes:
      - jf_config:/config
      - /mnt/media:/media:ro
    restart: unless-stopped

  # DNS Filtering
  pihole:
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
    volumes:
      - pihole_data:/etc/pihole
    environment:
      - TZ=Europe/London
    restart: unless-stopped

  # Monitoring
  uptime-kuma:
    image: louislam/uptime-kuma:latest
    volumes:
      - kuma_data:/app/data
    restart: unless-stopped

volumes:
  caddy_data:
  caddy_config:
  nc_data:
  nc_db_data:
  vw_data:
  jf_config:
  pihole_data:
  kuma_data:

Compose Commands

# Start all services
docker compose up -d

# Stop all services
docker compose down

# Update all images
docker compose pull
docker compose up -d

# View logs for a specific service
docker compose logs -f nextcloud

# Rebuild after Compose file changes
docker compose up -d --force-recreate

Container Networking

By default, Compose creates a dedicated bridge network where services reach each other by container service name. Splitting public proxies and internal databases onto separate networks limits lateral exposure:

networks:
  frontend:
    driver: bridge
  backend:
    driver: bridge

services:
  caddy:
    networks:
      - frontend
  
  nextcloud:
    networks:
      - frontend
      - backend
  
  nc_db:
    networks:
      - backend

Here, PostgreSQL listens only on backend, unreachable from the reverse proxy.

Updates and Maintenance

Watchtower for Routine Updates

Watchtower checks registries for updated images on a schedule:

services:
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_SCHEDULE=0 0 4 * * *  # 04:00 daily
    restart: unless-stopped

Caution: Unattended major upgrades can introduce breaking schema changes. Prefer notification-only mode for databases and core apps, and pin explicit minor tags where stability matters.

Resource Limits

Cap CPU and memory so one runaway container cannot starve the entire host:

services:
  nextcloud:
    image: nextcloud:latest
    deploy:
      resources:
        limits:
          cpus: "2.0"
          memory: 2G
        reservations:
          cpus: "0.5"
          memory: 512M

Health Checks

services:
  nextcloud:
    image: nextcloud:latest
    healthcheck:
      test: ["CMD", "curl", "-f", "http://192.0.2.10:80/status.php"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

Beyond Docker Compose

When a single server reaches capacity:

  • Docker Swarm: Lightweight multi-node clustering built straight into Docker Engine.
  • K3s (Lightweight Kubernetes): Useful for learning Kubernetes concepts across small clusters, though heavier than needed for a single home box.
  • Nomad: HashiCorp scheduler capable of mixing containers with standard binaries and virtual machines.

For most personal stacks, one well-backed-up Linux host running Docker Compose covers everything reliably.

Product links may include affiliate partnerships. See our affiliate disclosure for details.