Skip to content

Docker Compose

Docker Compose defines and runs multi-container applications from a single declarative YAML file (docker-compose.yml). For self-hosting it's the backbone pattern: one service = one directory = one compose file, making every app independently deployable, backupable, and removable.

The self-hosting pattern (the one this box uses)

Each service lives in /srv/<service>/ with its own docker-compose.yml, .env, and data/. Benefits: ls /srv/ shows everything deployed; cp -r backs one up; rm -rf cleanly removes it. This beats one monolithic compose file where a single change risks everything. See stack-sovereignty-box.

Key facts

  • Declarative YAML: images, ports, volumes, networks, env, healthchecks, resource limits.
  • deploy.resources.limits (memory + cpus) is honored by docker compose outside Swarm — a common myth says otherwise. Always set both on a small box.
  • Bind mounts (./data:/data) are preferred for anything you want to back up or let the owner see; visible on the host and captured by the nightly tar.
  • Log caps matter: the default json-file driver grows unbounded and can fill a small disk. Set max-size/max-file per service and daemon-wide.
  • A shared external network (here srv-net) lets caddy route to any container by name.

What it replaces

Hand-run docker run commands, ad-hoc process management, and heavier orchestration (K8s) that a single small VPS doesn't need.