From Kubernetes to Docker Swarm: a self-hosted container pipeline that (mostly) runs itself

For a while my homelab ran on Kubernetes. It worked — but it was a lot of
platform for a one-person lab, and most of what I was maintaining existed to
support the platform itself, not the apps on it. So I rebuilt the whole thing
on Docker Swarm and a two-repo Gitea Actions pipeline, with a private OCI
registry, shared NFS storage, and a small pile of tools I vibecoded around it.

This post is the tour: what Swarm actually is, why I moved off Kubernetes, what
my environment looks like, how the build/mirror/deploy pipeline works, the
little tools that sit on top of it — and what updating a running app looks
like when it’s all wired together (spoiler: a version-number bump in one
YAML file).

No cloud, no managed services, and no secrets in this post.

What Docker Swarm is — and why I left Kubernetes

Docker Swarm is Docker’s built-in container orchestrator. It ships inside the
Docker daemon you already have; there is nothing extra to install.

  • docker swarm init --advertise-addr <ip> on one node makes it the manager
    — it holds the cluster state and makes scheduling decisions.
  • docker swarm join <token> on the others makes them workers.
  • You deploy services described in a stack file — which is just a
    Compose file — with docker stack deploy.
  • The routing mesh publishes a service’s port on every node: connect to
    any node’s IP on that port and you reach the task, wherever it’s running.
  • Overlay networks connect containers across nodes; restart policies
    and rolling updates come from the same stack file.

That’s the entire feature list you need to hold in your head. Which brings me
to the actual decision.

What Kubernetes gave me vs. what it cost me

What I actually used Kubernetes for: rescheduling when a node died, restart
policies, one stable address per app, declarative YAML in git, and deploys by
push. Every one of those has a first-class, simpler equivalent in Swarm.

What it cost me to get them: a control plane to keep alive (API server, etcd,
scheduler, CNI, CSI, cert-manager, an ingress controller, metrics), Longhorn
for storage, Helm charts for every app, a Tailscale operator plus per-app
Cloudflare tunnels to expose anything, and upgrade paths that were weekend
projects in themselves. For a single admin and about ten apps, that’s
operational overkill — most of my time went to the platform, not to anything
the platform was for.

Swarm’s pitch is the reverse trade: roughly 90% of what I actually used, for
maybe 5% of the moving parts. The orchestrator is inside Docker, the stack
file is a Compose file, deploy is one command, and the only things I run
besides containers are a registry and a file server.

To be fair to Kubernetes, the trade only makes sense because: I’m one person;
the apps are a handful of single-replica services; I don’t need
autoscaling, operators, or a CRD ecosystem; and I’m not running this to learn
Kubernetes for a job. If any of those change, the migration conversation
reopens.

The environment

Six Ubuntu 24.04 VMs, all amd64, spread across two Proxmox VE servers —
and this is the part I like: because every node is joined to the swarm over
Tailscale, the swarm doesn’t know or care which physical box a VM lives
on. Live-migrate a worker between Proxmox hosts, or rebuild it entirely on the
other one, and the cluster is unbothered.

HostRole
swarm-managerSwarm leader; runs the deploy runner (the Gitea Actions job that deploys stacks)
swarm-worker1–swarm-worker4Swarm workers
nfsShared storage (NFS) + the private OCI registry
buildCI build runner (the Gitea Actions job that builds and mirrors images)

The manager’s job, in one paragraph. It holds the cluster state and makes
the scheduling decisions — when a task dies it decides where the replacement
runs. It’s also the entry point for docker stack deploy, which is why the
deploy runner lives on it. It runs user workloads too (a single-manager
swarm is fine at homelab scale — you lose control-plane redundancy, not the
running services, if it reboots).

Tailscale is the fabric. The swarm control plane (2377), gossip (7946) and
VXLAN (4789) traffic all ride the tailnet, and --advertise-addr is the
manager’s Tailscale IP. Every node reaches every other by name; the NFS
exports are scoped to the Tailscale CGNAT range (100.64.0.0/10).

Shared storage, so tasks can land anywhere. The nfs host exports
/opt/docker/data; every node mounts it at the same path. A stack
bind-mounts /opt/docker/data/<app> into the container, so whichever node
the scheduler picks, the data is already there. (Yes — SQLite-on-NFS is a
locking-semantics topic. At homelab write loads it’s been fine, and
“container data follows the container” is worth it. A genuinely
write-heavy database would get local volumes instead.)

Gitea with Actions runs as a container elsewhere on the LAN. Runners are
installed in host mode on the build server and on swarm-manager, kept
apart by labels — build jobs can never land on the production manager, and
deploy jobs never land anywhere else.

dockervision: seeing what the swarm is doing

The first thing I vibecoded for this environment was
dockervision — a realtime dashboard for the swarm.

The design constraint I cared about: nothing gets installed on the swarm.
No agents, no exposed Docker API ports. The dashboard simply SSHes into each
node with my existing keys and aliases (swarm1, worker1, …) and polls the
Docker CLI (docker ps --size, docker stats, docker system df) plus
/proc counters on each node.

What it gives me:

  • A left pane of masters and workers with role badges, status dots and live
    CPU sparklines.
  • Swarm-wide CPU/RAM/disk/network totals with graphs.
  • A per-app grid (grouped by stack) that drills down: app → services →
    individual containers/tasks, each with live stats.
  • A per-device view of every node, including Docker’s own disk usage.

It’s the difference between knowing my configuration (which Portainer
already shows) and knowing what the cluster is actually doing at 2am — and
when a node’s CPU is quietly ramping, the sparkline tells me before anything
else does. Updates stream over SSE, so the page is live without ever
refreshing.

homelab_docker_build: build your own images, or mirror everyone else’s

The first of the two pipeline repos is
homelab_docker_build.
It answers the question “where do the swarm’s images come from?” — and it has
two answers, because there are two kinds of image in a homelab.

1. Images I build myself. Anything I’ve written (or “vibecoded”) lives
under apps/<name>/ with a Dockerfile and optionally a test.sh. On push to
the build branch, a Gitea Action on the build server builds every changed
app, smoke-tests it (the container must still be up after 5s, or the app’s
own test.sh runs), then deletes the images again — nothing lingers on the
build host. When the PR merges to main, a release action re-builds and
pushes it to the private registry as <app>:build-<run> and :latest.

2. Images everyone else built. Third-party apps (termix, guacd, wordpress,
mysql, …) don’t need building — they need mirroring. A
mirror-images.json lists upstream references:

{ "name": "termix",    "source": "ghcr.io/termix-ssh/termix:latest" },
{ "name": "guacd",     "source": "docker.io/guacamole/guacd:1.6.0" },
{ "name": "mysql",     "source": "docker.io/library/mysql:8.0" }

On push, the mirror action pulls each one and pushes it into the private
registry. The clever bit: for latest-style sources it resolves the real
upstream version by digest-matching
the upstream registry’s version tags,
so ghcr.io/termix-ssh/termix:latest lands in my registry as termix:26.10.1
— an actual version, not a moving target. (Implementing that taught me more
than I wanted to know about Docker Hub’s tag pagination, but that’s another
section.)

What zot is, and why self-host a registry

The private registry is zot — an
open-source, cloud-native OCI image registry. It’s a single Go binary with
no database, htpasswd auth, and a JSON config; it runs as a systemd service
on the NFS host behind nginx, TLS terminated there.

Why bother, when Docker Hub exists:

  • No rate limits, no upstream outages. The swarm pulls everything from
    the LAN.
  • One place holds every image the homelab needs, so a Docker Hub
    account, a GHCR quota and an internet connection are no longer
    deploy-time dependencies.
  • Determinism. Which brings me to the rule I’d defend hardest:

Version numbers, not :latest

Every image in the registry carries its real version tag — termix:26.10.1,
wordpress:7.1.3, mysql:8.0, anchor:0.9.1 — and every deployed stack
references the version tag, never :latest.

The payoff is that a deploy becomes a diff you can read. “What’s running?”
is a grep, not a memory. “What changed in this upgrade?” is one line in one
file. And if an upgrade goes sideways, the previous version is still sitting
in the registry, one edit away.

homelab_docker_deploy: YAML in, services out

The second repo is
homelab_docker_deploy.
One directory per app, one Swarm stack file each. A typical one:

services:
  anchor:
    image: zot.safehomelan.com/anchor:0.9.1   # pinned version, from my registry
    volumes:
      - type: bind
        source: /opt/docker/data/anchor     # shared NFS — task lands anywhere
        target: /data
    ports:
      - "3001:3000"                          # published on every node (mesh)
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure

On push to main, a Gitea Action — running on the manager itself, thanks
to the runner labels — logs into the registry and runs
docker stack deploy --with-registry-auth for every changed stack. The
--with-registry-auth matters: it distributes the registry credentials to
the workers so whichever node needs to pull from the private registry, can.

So the deploy story is: push = deploy. Re-running a stack is a rolling
update. Reverting is reverting the commit. There is no step where I
docker anywhere by hand.

flowchart LR
  Dev["edit apps/ or mirror-images.json"] -->|push to build| R1["homelab_docker_build<br/>(Gitea Action on build host)"]
  R1 -->|build + smoke test<br/>or pull + version-resolve| Z["zot registry<br/>(version tags, not latest)"]
  Dev2["edit stacks/<app>/stack.yml"] -->|push to main| R2["homelab_docker_deploy<br/>(Gitea Action on the manager)"]
  R2 -->|docker stack deploy<br/>--with-registry-auth| SW["swarm (5 nodes, 2 proxmox boxes)"]
  Z -.pull.-> SW

deploywizard and deploygui: vibecoded front doors

Here’s the thing about the pipeline above: every step in it is a git
command, a curl at the Gitea API, or an ssh — a short, fully-known
runbook. That is exactly the shape of problem an LLM builds well, and more
importantly, it’s a runbook I wanted enforced rather than remembered.
So I vibecoded two tools to be the front doors.

deploywizard

A question-driven terminal wizard for the whole pipeline. It asks everything,
shows a review screen, and on confirmation drives the lot: mirror or build →
PR and merge → stack file → deploy → reverse-proxy domain → verification.

What it asks for a new service: prebuilt upstream image (mirrored into
zot) or self-built Dockerfile; an optional upstream docker-compose.yml URL,
which it imports — ports, volumes and env prefilled, and Swarm-incompatible
features flagged (env_file, depends_on conditions,
network_mode: service:*); the stack name and ports (it scans the five
nodes for a free port
and suggests one); data directories, which it creates
on the shared NFS; env vars, with secrets generated as random hex; a
healthcheck; and whether you want domains wired up on the nginx proxy
manager. For an update, it lists everything in the pipeline — every
mirror entry, every app, every stack — and asks what kind of update you’re
doing (mirror refresh, app rebuild, stack image bump, stack config change).

The safety properties are the reason I trust it: nothing executes before the
review screen; all git mutations happen in temporary worktrees so my
checkouts are never touched mid-edit; pushes to protected branches fall back
to PR + merge via the API; and it’s idempotent — a re-run collides loudly
instead of duplicating anything. There’s even an answers-file mode
(--from answers.json --yes) so a fully-specified deploy runs end-to-end
unattended.

deploygui

The same pipeline as a local web UI in four panes:

  • Build: local images — the build repo’s apps with their tags in the
    registry; one button commits your local changes to the build branch and
    pushes, triggering the build-and-test action.
  • Build: mirrors — the mirror-images.json entries with their resolved
    tags; buttons to refresh them all or add a new image.
  • Deploy — every deployed stack with a tag dropdown per service.
    Pick a different version, hit Update, and it rewrites the stack file,
    commits and pushes — which is the entire upgrade, done.
  • Status — every Gitea Action rendered as a live checkbox list with a
    streaming log tail, plus the health of the registry, Gitea and the build
    server.

Together they answer the three questions of day-to-day ops — what’s running,
at what versions, and what did CI just do
— without opening a terminal, and
turn “add a new service” from a checklist I could get wrong into a wizard
that refuses to skip steps.

Updating an app is a version bump

This is my favourite part of the whole design, so it gets its own section.
Upgrading any mirrored app end-to-end:

  1. Bump the pin in mirror-images.json (say mysql:8.0 → 8.1) and
    push — the mirror action pulls the new version into the registry.
  2. Bump the tag in stacks/<app>/stack.yml
    (image: zot.safehomelan.com/mysql:8.0 → 8.1) and push to main.
  3. The deploy action rolls the service. Done.

Two one-line diffs, two pushes, one rolling update — and because both
repositories keep full history, “what changed, when, and why” is answered by
git log.

A real example from this environment: termix went 26.10.1 → 26.10.2
exactly like this, first via the wizard and later through deploygui’s tag
dropdown — same two-line change, executed by different front doors onto the
same boring pipeline underneath.

For self-built apps the same shape holds with the release action’s
build-<n> tags: merge the PR, pick the new build number in the stack file,
push.

Gotchas worth keeping

For anyone replicating this, the short ledger of things that bit:

  • Post-reboot overlay weirdness. After a node reboot (or a VM CPU-type
    change under Proxmox), cross-node overlay traffic can quietly break while
    everything looks healthy — services up, local ports answering, but
    container-to-container paths across nodes refusing. systemctl restart docker on the affected node has fixed it every time. If a swarm node
    reboots, it’s worth a connectivity smoke-test, not just a status check.
  • Shallow fetches break three-dot diffs in CI. A
    git fetch --depth=1 origin main inside a workflow leaves no merge base,
    so git diff origin/main...HEAD errors, the guard reads it as “nothing
    changed”, and the workflow succeeds in one second having done nothing.
    Two-dot diffs are the robust guard.
  • Docker Hub’s tag API paginates with relative Link URLs, its first
    page can be years of old tags, and the registry host is
    registry-1.docker.io — all three matter if you’re digest-matching
    versions.
  • nginx in front of a registry needs client_max_body_size 0; —
    semicolon included; a config error there quietly never activates the vhost
    and every push dies at 1 MB.
  • Keep an escape hatch from your own registry. This week zot started
    rejecting every manifest push with 415 manifest invalid (blobs fine,
    existing images fine — a registry-side regression I’m still chasing). One
    stack now pulls straight from Docker Hub until it’s fixed, and nothing
    about the pipeline cared. Private infrastructure is great right up until
    it’s the thing that’s broken.

Thoughts

Everything that defines the system lives in Git or on the NFS share. The
two repos describe every image and every stack; the Ansible playbooks describe
every host; the runners and the registry sit on machines those playbooks can
rebuild. There is no server in this environment whose loss means guessing
what was on it.

The simplicity dividend compounds. The whole platform is: Docker, two
repos, two Actions, one registry binary and one NFS export. That’s nearly
nothing to patch, nothing to re-certify, and — the real payoff — nothing I
can’t debug over SSH in an afternoon. Kubernetes taught me a lot, but most
of the lessons were about Kubernetes.

Pinning versions in a local registry makes deploys boring, and boring is
the goal.
A deployment I can read as a one-line diff is one I can review
at a glance, revert in one push, and trust six months later.

Vibecoded tooling on top of deliberately boring infrastructure is a
fantastic trade.
The infrastructure is stable because it’s simple, and
the tooling around it was cheap to build because the runbook is small and
fully known. dockervision, deploywizard and deploygui each took an evening,
and each one removed a whole class of “did I do all the steps?” from my life.
The tools can be rough — the infrastructure underneath them can’t afford to
be.

What I’d still like to fix. A second manager for control-plane HA; an
image retention policy in zot so old versions don’t accumulate forever; and
actually exercising the full-rebuild path — wipe a node, replay the
playbooks, prove the “everything is described somewhere” claim the hard way.

If you’re running a homelab Kubernetes cluster and enjoying it — genuinely,
keep it; the ecosystem is unmatched and the learning transfers. But if
you’re maintaining the platform more than the apps on it, Swarm is a
perfectly good answer that has been quietly shipping in dockerd this
whole time.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *