Skip to content

Lesson 6 of 9 · 28m

Running Services Like Production Instead of Pets

Use repeatable deployment, explicit configuration ownership, least privilege, secrets discipline, and rollback paths for self-hosted applications.

A home lab becomes valuable when you stop administering every service as a unique handcrafted creature. Production discipline is not enterprise theater. It is the difference between fixing an upgrade in ten minutes and reconstructing a mystery machine from memory at midnight. The target is repeatability: if the host died, could you rebuild the service without guessing?

Every service needs an owner contract

Even if the only operator is you, write the contract down:

service name/host     files on vm-files.lab.internal
data paths            /srv/files/data, /srv/files/config
secrets/exposure      encrypted env file; proxy-only service VLAN path
backup/upgrade        nightly restic; pinned compose upgrade with rollback snapshot
health                GET https://files.example.net/healthz

This is not bureaucracy. It is future incident response written in advance.

Containers are packaging, not isolation magic

Docker and Compose are useful because they make deployment repeatable:

services:
  files:
    image: ghcr.io/example/files:2.8.1
    restart: unless-stopped
    read_only: true
    user: "10001:10001"
    ports: ["127.0.0.1:8080:8080"]
    volumes: ["/srv/files/data:/data"]
    secrets: [files_db_url]

secrets:
  files_db_url:
    file: /run/secrets/files_db_url

But containers share the host kernel. Do not treat them as strong multi-tenant isolation. Drop capabilities, avoid privileged containers, pin versions, mount only needed paths, and never expose the Docker socket to an application because the dashboard looked convenient.

Configuration drift is the silent killer

The first deployment is easy. The fifth hand-edited configuration is the one nobody can reproduce. Keep service configuration in git. Use a private repository or encrypted secrets solution depending on sensitivity. Even a simple layout helps:

services/
  files/
    compose.yaml
    README.md
    files.example.net.caddy
    backup.env.age

Pin image tags. latest means every rebuild is a surprise upgrade with no review opportunity. Pinning does not prevent patching; it makes patching deliberate.

Identity and authorization still matter at home

Self-hosted applications often assume trusted users. Then someone exposes them publicly. Prefer applications with OIDC support or place them behind an identity-aware layer. Use separate service accounts rather than a single administrator credential shared by every integration.

bad:   every automation uses the root NAS API key
good:  backup writer can write snapshots, monitoring can read health, admin is separate

If an application stores passwords in plaintext config or requires disabling verification to function, that is not quirky self-hosting. That is risk.

Upgrades need rollback, not optimism

Before touching a stateful service:

zfs snapshot tank/files@before-2.8.1
docker compose pull
docker compose up -d
docker compose logs --since=10m -f

Know how migrations behave. Some database migrations cannot be reversed by simply starting the old image. In those cases the rollback is restore from backup or snapshot, not downgrade. Say that in the README before you need it.

Inventory is a security control

You cannot patch what you do not know exists. Keep a lightweight inventory generated or reconciled regularly. Include exposed ports, image versions, public hostnames, data classifications, and dependencies. The lab's biggest security problem is usually abandoned software still reachable.

Field notes

  • restart: unless-stopped is not high availability. It only restarts processes on a healthy host.
  • Do not store secrets in shell history, compose files committed to git, screenshots, or backup scripts with broad permissions.
  • Host firewall rules still matter inside a trusted LAN. Assume another VLAN or container escape can reach the host.
  • The first time you say "I will document this after it works," write at least the commands you ran into a scratch note. Memory is not version control.

Was this lesson helpful?

Sign in to rate