Six months into running a small self-hosted estate — Gitea, Nextcloud, a Grafana, an Authentik, a Garage S3 — the operator opens the dashboard and finds: Gitea is three minor versions behind, Nextcloud has a red banner saying “your version has reached end of life,” Authentik shipped four security advisories that nobody acknowledged, and the host OS is missing 47 unattended-upgrades because someone disabled the timer to “make sure nothing changes during a release.” Nothing is on fire. Nothing is current either. This article is the cadence that prevents that drift and the procedure that keeps it honest.
How to verify
A healthy estate has these signs:
# Host OS is up to date on security patches
ubuntu-security-status --thirdparty 2>/dev/null | head -3 || apt list --upgradable 2>/dev/null | wc -l
# Unattended-upgrades is enabled and ran recently
systemctl list-timers apt-daily apt-daily-upgrade --no-pager
grep -hE 'Started|Finished' /var/log/unattended-upgrades/unattended-upgrades.log | tail -5
# Docker image ages — anything more than 90 days is a candidate for review
docker images --format '{{.Repository}}:{{.Tag}} {{.CreatedSince}}' | sort -k2
# App version against latest stable
# Gitea
curl -fsS https://your-gitea.example/api/v1/version | jq -r .version
# vs https://gitea.com/api/v1/version (or release feed)
# Nextcloud
sudo -u www-data php /var/www/nextcloud/occ status | grep version
# vs https://nextcloud.com/changelog/
# Authentik
docker compose -f /opt/authentik/docker-compose.yml exec server ak version
# vs github.com/goauthentik/authentik/releases
# Last backup that successfully restored in a rehearsal
ls -la /var/log/backup-restore-rehearsal.log
If the OS has 40 pending security patches, the timer is disabled. If a container image is 280 days old, the cadence is broken. If the version-check returns nothing and you have to fish through release notes manually, the cadence isn’t measured. All three are common in estates that “ran themselves” for a year.
What’s happening
A self-hosted estate has four different categories of update, on four different cadences:
-
OS security patches — the kernel, openssl, sshd, glibc, the things every other layer depends on. Cadence: continuous, via unattended-upgrades for security pocket only. This is the only category that should auto-apply unattended.
-
Container images for stateless apps — Authentik, Authelia, Grafana, Nginx, fail2ban, the things that don’t hold persistent state in the container itself. Cadence: weekly. Pinned to a minor version (e.g.,
:2024.10), bumped to the next patch within that minor on a weekly cadence, and to the next minor every month or two after release-note review. -
Container images for stateful apps with on-disk schemas — Gitea, Nextcloud, PostgreSQL, MariaDB, Redis. Cadence: monthly with a maintenance window. A version bump here triggers schema migrations that you don’t want firing at 3 a.m. on a Tuesday under autoupdate.
-
Major-version upgrades — PostgreSQL 15 to 16, Nextcloud 28 to 29, Keycloak 23 to 24. Cadence: quarterly, with a planned window, a backup, a rehearsal, and a rollback plan.
The mistake almost every small estate makes is collapsing all four into one cadence — either “Watchtower runs nightly and updates everything to :latest” (which breaks at 4 a.m. when Nextcloud requires a manual schema migration), or “we don’t update anything until the audit forces us to” (which leaves the OS shipping vulnerabilities for nine months).
The procedure
-
Pin image tags to a minor version, never
:latest. In every compose file, replaceimage: authentik/server:latestwithimage: authentik/server:2024.10. The minor is what you read changelogs for; the patch is whatdocker compose pull && docker compose up -drolls forward to.:latestis for demos. -
Enable unattended-upgrades for security pocket only. On Ubuntu/Debian:
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'EOF' APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1"; APT::Periodic::AutocleanInterval "7"; EOF cat > /etc/apt/apt.conf.d/50unattended-upgrades.conf <<'EOF' Unattended-Upgrade::Allowed-Origins { "${distro_id}:${distro_codename}-security"; "${distro_id}ESMApps:${distro_codename}-apps-security"; "${distro_id}ESM:${distro_codename}-infra-security"; }; Unattended-Upgrade::Automatic-Reboot "false"; Unattended-Upgrade::Mail "ops@example.com"; EOFThis auto-applies security patches only; non-security updates stay manual. Reboot is manual — kernel patches need the reboot, but you decide when.
-
Run a weekly “pull and restart stateless” cron. For containers with no on-disk schema, weekly is fine:
# /etc/cron.d/weekly-stateless-pull 30 03 * * 1 root /usr/local/bin/weekly-stateless-pull.sh >> /var/log/weekly-pull.log 2>&1#!/usr/bin/env bash set -euo pipefail for stack in /opt/authelia /opt/authentik /opt/grafana; do cd "$stack" docker compose pull docker compose up -d done docker image prune -fThe
--no-recreateshape isn’t right here — you want recreate when the image hash changes — but the script as written is whatup -dalready does. -
Run a monthly maintenance window for stateful apps. Pick a Saturday morning. Announce the window. Steps:
# Pre-flight docker compose -f /opt/gitea/docker-compose.yml exec -T db pg_dumpall -U gitea > /backup/gitea-pre-update-$(date +%F).sql # Read the changelog # gitea: https://github.com/go-gitea/gitea/blob/main/CHANGELOG.md # nextcloud: https://nextcloud.com/changelog/ # Bump the tag in the compose file (e.g., 1.21.10 -> 1.21.11) $EDITOR /opt/gitea/docker-compose.yml # Pull, restart, verify cd /opt/gitea docker compose pull docker compose up -d docker compose logs --tail=200 -f curl -fsS https://gitea.example.com/api/v1/versionIf the app needs a one-shot migration command (Nextcloud’s
occ upgrade, Gitea’smigrate), run it after the container is up. Watch the logs for ten minutes before declaring done. -
Schedule major-version upgrades as projects. A PostgreSQL 15 → 16 upgrade is not a cron job. It needs a backup, a clone of production to a test VM, the upgrade rehearsed end-to-end on the clone, the rehearsal documented as a runbook, and the production window booked. Same for Nextcloud N → N+1, Keycloak realm migrations, and any tag jump where the changelog has a “Breaking changes” section.
-
Measure the cadence. Keep a simple text file per app:
/opt/cadence/gitea.txtwithversion | installed_on | applied_by | notes. Cron-run a script weekly that compares the current version to the upstream release feed and emails the gap. If you can’t see “we are 2 patches behind,” you can’t decide to fix it.
Common pitfalls
-
Watchtower across the whole estate. Watchtower polls Docker registries and auto-updates anything tagged
:latest. On a Friday at 4 p.m. it bumps Nextcloud to a new major version that needsocc upgrade, the container starts the migration, the migration times out, and nobody is on call. Use Watchtower only on truly stateless containers you’ve verified handle rolling restarts cleanly. -
Skipping
docker compose pullbecause “we have local images.” Thedocker compose up -dcommand does not pull unlesspull_policy: alwaysis set. If you bumped the tag in the compose file but didn’tpull, you restarted the old image. Always pull before up. -
Backups taken during the same maintenance window as the upgrade. Take the backup as a separate pre-step, verify it landed, verify its size against yesterday’s backup. Then upgrade. A backup that doesn’t complete before the upgrade starts is no backup at all.
-
No rollback plan. Before bumping a tag, write down the tag you are rolling back to and the command (
docker compose down && git checkout HEAD~1 docker-compose.yml && docker compose up -d). When the upgrade goes sideways at 2 a.m., the operator on call should not be improvising. -
Skipping the patch when the release notes look “minor.” A “minor bugfix release” sometimes contains the security fix that wasn’t tagged as such. Treat the cadence as the cadence; read the changelog for awareness, not as a reason to skip.
Operational notes
The smallest sustainable estate (under 10 containers) can run this whole cadence in 30 minutes a week plus a 90-minute maintenance window per month. The biggest mistake is letting that 30 minutes slip — once it slips to 60 minutes one week and 0 the next, the gap compounds. Treat it as a calendar item, not a “when I get to it.”
We operate the patch cadence for self-hosted estates so the calendar item doesn’t slip and Friday afternoon isn’t a maintenance window. See Managed Cloud Operations.