Technology

It's all containers

11 Oct 2026

Six apps, two languages, one weekend, and a much better night's sleep.

I run a small home server that hosts most of what I build: my own sites, a few apps for diving clubs, a company website, and an assortment of experiments. Over time it had grown the way home servers do. Every app had its own deploy script, and no two worked the same way. Some were compiled on the server itself, others cross-compiled on my laptop and copied over. Each ran as its own systemd service, with its SQLite database sitting in a folder in my home directory. Nothing was backed up anywhere but the server.

This weekend I finally cleaned it all up.

What was there

When I took inventory, it was worse than I thought:

  • Two Docker installations side by side, one from a snap and one from the distribution, fighting over the same socket.
  • A leftover Docker Swarm, still listening for cluster traffic nobody would ever send.
  • A broken Docker context that made the server SSH into itself about 1,700 times a minute, until SSH's own abuse protection started locking me out.
  • Two apps nobody used any more, plus a database server and a print server with nothing left to serve.
  • Zero off-server backups.

Docker Compose, not Kubernetes

I considered Kubernetes for about five minutes. It's one machine running a handful of small apps. Kubernetes would add a control plane, an ingress controller and a pile of YAML, all to solve problems I don't have. Docker Compose gives me what I actually need: one declarative file per app, restart policies, persistent storage for the databases, and rollback by changing an image tag. The web server in front of everything (Caddy, handling TLS) stayed exactly where it was.

The end result:

  • Six codebases, three in Rust and three in Go, plus a Flutter web client. They now run as nine app containers plus a database, since one codebase serves two sites and another is an API, a web client and their own Postgres.
  • Two dead apps and a legacy service retired, along with the unused database server and print server.
  • A monitoring stack of seven more containers.

Every app is built the same way now. A multi-stage Dockerfile compiles everything inside the build, including the Tailwind and Flutter steps, so my laptop needs no toolchain at all. The Go apps end up in distroless images of around 16 MB with nothing in them but the binary. The Rust ones need a slim Debian base and land around 100 MB. Each deploy script is the same shape:

  1. build on the server;
  2. back up the database;
  3. start the new version and wait for it to answer;
  4. roll back automatically if it doesn't.

Moving each app over cost between 7 and 30 seconds of downtime.

The firewall trap

The one thing I'd tell anyone doing this: ports Docker publishes skip your firewall. Docker writes its own iptables rules, so a container published on 0.0.0.0 is reachable from the internet even if UFW says otherwise. Every container here publishes on 127.0.0.1 only, and Caddy is the only way in. From the outside, the server now shows exactly two things: SSH and the web.

While I was at it, every container got the same hardening:

  • it runs as a non-root user, with a read-only filesystem;
  • all Linux capabilities are dropped and privilege escalation is disabled;
  • memory and process limits are set.

SSH became key-only, too.

Seeing what's going on

For the first time I have a dashboard:

  • Prometheus for metrics, with cAdvisor for each container and node-exporter for the host.
  • Loki for logs, fed from the systemd journal, which Docker now logs into.
  • A blackbox prober that checks every site once a minute, including when each TLS certificate expires.
  • Grafana on top, behind Google sign-in.

Alerts arrive by email: a site down, a certificate close to expiring, a full disk, a failed service, a backup that didn't run, a container near its memory limit.

Backups I can actually restore

There are now two layers:

  • On the server: a nightly job takes a consistent online copy of every SQLite database.
  • On my laptop: a scheduled job pulls a complete snapshot every night. That means databases, uploaded photos and videos, Postgres dumps, secrets, web-server config and the dynamic DNS updater.

Unchanged files are hard links into the previous snapshot, so every snapshot is complete but a quiet night costs about 2 MB.

The part I'm proudest of is restoring. One command puts any app, or everything, back, owners and permissions included. A drill mode restores into a scratch folder so I can prove a backup works without touching anything live. Rebuilding the whole server on new hardware is now a five-step checklist: install the OS, run a setup script, run the restore.

What bit me

It wasn't all smooth, and the lessons were all about silent failures:

  • A deploy script that reported success after doing half its job. A command inside it quietly read the rest of the script as its input. That cost one site about a minute of downtime.
  • Pre-deploy backups that had never run for one app. The script checked for the database file without permission to see it, decided there was nothing to back up, and carried on.

Neither produced an error message. Now scripts check that each step really did what it should, instead of trusting a clean exit.

Was it worth it?

Absolutely. Deploying any app is now the same one command. Every container is locked down the same way, I can see what everything is doing, and for the first time a dead disk would be an inconvenience instead of a disaster. It took one long day, with an AI coding assistant doing most of the typing while I made the decisions.

Comments

No comments yet.

Log in to leave a comment.