Runners

Runners is a self-hosted control plane for Docker applications. I use it to deploy apps across Linux machines and manage them from one dashboard.

Rust, Go / etcd Raft, Docker, Cloudflare D1

The system at a glance

The control plane decides what should run and where. An agent runs on each Linux host, applies the work assigned to that host, and reports what is actually happening.

Logical overview. One agent host is shown; the fleet runs one agent per host.
Dashboard / CLISubmit app definitions and changes

Control plane

Chooses and coordinates work

Rust controllerHTTP API, validation, scheduler
Go Raft helperElections and leadership checks
Elected leaderRaft peers
Assigned plans
Inventory
Health
Metrics
Agent opens the
authenticated WebSocket

Agent

Runs work on one Linux host

Rust agentApplies its approved plan
Docker / ComposeBuilds and runs app containers
Local proxy + connectorsRoutes traffic to ready apps
Private host stateIdentity, inventory, plans, receipts
D1External, durable app configuration

Control plane: making the decisions

The control plane receives Compose definitions and desired replica counts, stores configuration, and chooses placements using the fleet’s reported capacity, region constraints, and current inventory.

Control plane: turn desired state into host-specific work
  1. ValidateCheck the app definition and requested changes
  2. CommitConfirm desired configuration in D1
  3. ReconcileCompare desired state with agent reports
  4. Issue plansRelease work under current leadership
API and configuration
Validate changes and confirm configuration commits before acknowledging them.
Scheduling
Choose eligible hosts, reconcile desired copies with actual inventory, and coordinate moves and recovery.
Leadership
The official etcd/raft helper handles elections and membership. Quorum-confirmed ReadIndex checks guard work and plan release.
Public addresses
Manage the app’s Cloudflare DNS and tunnel definitions. The agents operate the local connectors.

A recursive control plane

Runners can deploy its own controller replicas as an ordinary app. The control plane schedules those containers through the same agents that run my other applications, so the system manages part of its own infrastructure.

The controller is also a workload. External controller peers can participate in the same cluster.
Elected controllerReconciles applications, including the controller app

Host-specific plans

Agent fleet

Agent host ARegular applicationController replica
Agent host BRegular applicationController replica

Inventory reports and controller peer traffic close the loop.

The elected controller above is one of the cluster’s controller processes, shown in its scheduling role and its workload role.

The controller app uses ordinary readiness checks and moves. Its /readyz waits for voter admission and completion of any joint membership change. A replacement starts with a fresh Raft identity, joins as a learner, catches up, and replaces its predecessor through joint consensus.

CP_NODE_ID_OFFSET maps app replica numbers to logical controller slots when fleet-hosted and external peers share a cluster. x-runner.spread-tags: true prefers different server groups when eligible capacity allows.

etcd Raft and scheduling authority

Each controller pairs a Rust process with a supervised Go helper using the official go.etcd.io/raft/v3 library. The helper handles elections, replication, and membership; D1 remains the durable configuration store. Runners uses the Raft library without running an etcd database server.

A seven-voter example during a network partition: a majority requires four.

Connected group of 4

1234

Can elect a leader and confirm quorum

Isolated group of 3

567

Cannot authorize new scheduling work

Existing approved workloads continue running on agents on either side.

Mutual exclusion here means that only the quorum-confirmed leader may issue new plans. ReadIndex checks guard work and plan release; a stale leader’s local “leader” flag is insufficient. Without quorum, scheduling pauses.

Calls already sent to D1 or Cloudflare can finish after leadership changes. Configuration revisions guard commits, and the current primary reconciles routing. Raft authority does not cancel an external request already in flight.

Agent: doing the work on one host

An agent connects outward to the controller. It receives a host-specific plan rather than independently choosing the fleet’s replica count or placements.

Agent: apply the plan and observe the result
  1. ReceiveAccept the approved plan for this host
  2. RunBuild or start the assigned Compose projects
  3. ObserveProbe readiness and collect local metrics
  4. ReportSend inventory, health, and results back
Workload execution
Build images when needed and apply the assigned Docker Compose projects, versions, and local changes.
Local observation
Report container inventory, app readiness, and host and replica resource metrics. The native agent uses the Docker API for observations and the Docker CLI for workload changes.
Local networking
Maintain the host proxy and tunnel connectors. A shared app connector is active only while a local app copy is healthy and ready.
Continuity
Keep approved plans and recovery inventory locally. Existing authorized workloads can keep running while the controller is unreachable.

Placement and exclusion

The least busy host is useful only if it is eligible. Region rules, health, host lifecycle, Compose conflicts, and capacity all narrow the candidate set before the scheduler ranks it.

Filter first, then rank the hosts that remain
  1. RegionKeep the replica in its assigned region
  2. SafetySkip leaving, quarantined, or conflicting hosts
  3. CapacityCheck host limits, stacking, and startup work
  4. PreferencePrefer distinct hosts, tag diversity, and room
Hard constraints
Keep each replica in its configured region. Skip draining, departing, quarantined, or already-due hosts and hosts with conflicting ports or container names.
Replica separation
allowStacking defaults to false: copies of an app require distinct eligible hosts. Opting in permits compatible copies to share a host; host and region constraints still apply.
Failure exclusion
After a host-specific failure triggers recovery, that app avoids the host for six hours. If the same version fails on two hosts, Runners treats it as an app-level problem and stops that relocation heuristic.
Preferences
Prefer sufficient remaining host lifetime, room, and fewer existing placements. Optional tag spreading is best effort; a required region is strict. If no eligible capacity exists, the replica waits.

Balance useful work, avoid churn

The balancer handles sustained hot hosts, separates doubled-up copies when capacity returns, and moves settled workloads to reduce fleet pressure. Pressure is max(CPU %, RAM %), relative to each host’s capacity. The predicted cost of an app is converted to the destination’s capacity before admission.

Illustrative move between equal-capacity hosts. Bars show pressure; values are predictions, not live metrics.

Before

Host A70%70%CPU 70% · RAM 50%
Host B30%30%CPU 30% · RAM 30%

After moving one copy A → B

Host A55%55%CPU 55% · RAM 45%
Host B45%45%CPU 45% · RAM 35%

One copy uses 15 percentage points of CPU and 5 of RAM here. Predicted peak pressure falls from 70% to 55%.

A routine load move needs a pressure gap of at least 10 percentage points and a predicted peak-pressure improvement of at least 0.5 points. The destination must also retain a 10-point startup reserve below the 70% CPU and 80% RAM admission thresholds.

Move safely
Start the replacement first and retire the old copy only after readiness succeeds. If the replacement fails or times out, cancel the move and keep the working copy.
Exclude busy work
Routine balancing skips unsettled versions and hosts doing conflicting startup work. Only one routine move per app runs at a time; independent apps on disjoint hosts can move concurrently.
Let readings settle
Wait at least five minutes between an app’s routine moves after completion or cancellation, pace hosts separately, and allow three minutes for startup metrics to settle. Repeated hot-move thrashing pauses that app’s routine moves.
Recover separately
Confirmed failures bypass the routine balancing switch, pauses, and pacing. Eligibility and placement constraints still apply. Turning off routine balancing does not disable failure recovery.

Where an application request goes

The control plane handles management. Application requests travel through Cloudflare to a host’s local proxy and app container.

App traffic takes a separate path from management traffic
  1. VisitorRequests an app’s global URL
  2. CloudflareUses the app’s shared tunnel
  3. Host proxySelects a ready local replica
  4. ContainerServes the application request

The controller is outside this request path. Existing apps can keep serving during a controller outage; new placement decisions wait for an authoritative controller.

Where state lives

Configuration, observations, and app data have different owners.
LocationWhat it holdsLifetime
D1Desired app definitions, versions, and configurationDurable
Controller memoryRuntime reports, metrics, and Raft stateTemporary; members rejoin a surviving quorum
Agent host storageAgent identity, approved plans, inventory, and signed recovery receiptsPreserved locally across agent restarts
App volumesThe application’s files and local dataRemain on their host

Raft state is intentionally volatile in this design. Restarted members can rejoin a surviving quorum; loss of the entire quorum’s memory requires an explicit new-generation bootstrap.

What happens when something disappears

Replacing a replica after its host is lost
  1. Host missingAgent reports stop arriving
  2. RecheckApply liveness and recovery checks
  3. ReassignPlan a replacement on an eligible host
  4. Become readyA healthy connector serves the same app URL
Controller unavailable
Agents keep their approved workloads and healthy connectors. A surviving Raft quorum can elect a leader; without quorum, scheduling pauses.
Agent host lost
The controller uses liveness checks and inventory to plan replacement copies on eligible hosts. Agents start those copies and report readiness.
Local app unready
The agent withdraws that app connector. Other ready connectors can serve new requests through the same global hostname.

Reassigning a replica does not copy its local volumes. Applications that need shared state across hosts provide their own shared storage or replication.

A small configuration example

This requests three copies of a simple web server. The control plane turns the desired state into assignments; each agent applies only its own assignment.

x-runner:
  port: 8080
  replicas: 3
  ready: /

services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"

x-runner.replicas sets the desired copy count. x-runner.ready identifies the readiness path used to check whether a copy can serve requests.