Problem Statement: A Built-In Container Orchestrator
Frames Docker Swarm mode as an integrated control-plane and data-plane system, not a collection of Docker daemons.
Problem statement
Design a Docker Swarm: a cluster orchestrator that schedules containerized services across a fleet of machines, keeps declared desired state true, and ships traffic to the right tasks without any external dependency. The product must let an operator run a single command such as docker service create --replicas 10 and get ten running containers spread across nodes, replaced automatically when they die, updated with a rolling strategy, reachable through one virtual IP, and supplied with secrets that never land in an image or an environment variable.
Docker Swarm mode shipped in Docker 1.12 in 2016 on top of the swarmkit project, a Go implementation of the orchestration layer. Unlike the original external Swarm project, Swarm mode integrates consensus, scheduling, service discovery, networking, and secrets into the engine itself. Mirantis acquired Docker's enterprise division in 2019 and continues to ship Swarm alongside Kubernetes in Mirantis Kubernetes Engine, which is why this question still appears in Staff-level loops.
Why this is a system design problem and not a feature list
A container scheduler is a state machine driven by a reconciliation loop. The cluster declares desired state: services, replica counts, networks, secrets. Reality diverges constantly: nodes reboot, containers OOM, disks fill, networks partition. The orchestrator must converge reality onto the declared state while never double-scheduling capacity, never losing quorum, and never exposing a secret to a task that should not read it.
The design separates five planes. The management plane holds the only strongly consistent object in the system: the Raft-replicated cluster store. The orchestration plane watches the store and creates or removes tasks until observed matches desired. The scheduling plane assigns tasks to nodes. The data plane moves packets: VXLAN overlay networks and the routing mesh with IPVS. The security plane wraps everything: mutual TLS between all nodes, certificate auto-rotation, join tokens, and encrypted secrets.
The four invariants of a swarm
- Desired state convergence: every service eventually matches its spec.
- Quorum safety: no two leaders can commit conflicting cluster state.
- Task exclusivity: a node never runs more replicas of a slot than declared.
- Secret confidentiality: secret bytes exist only in manager memory, in the encrypted Raft log, and mounted into authorized task sandboxes.
Public baseline versus design assumptions
Public references establish feasibility. swarmkit's documented scalability design target is on the order of tens of thousands of tasks across roughly a thousand nodes, and Docker's operations guidance recommends an odd manager count between three and seven. These anchors frame the design. For capacity planning this answer explicitly assumes a mature mid-size swarm with 300 worker nodes, 5 managers, 3,000 services, and 30,000 running tasks. Unless a number is tied to a public reference, it is a stated design assumption, target, or budget.
Key Highlights
- •Swarm mode integrates consensus, scheduling, networking, and secrets inside the engine; there is no external key-value store.
- •Five planes: management (Raft), orchestration (reconciler), scheduling, data plane (VXLAN/IPVS), security (mTLS, secrets).
- •The Raft-replicated cluster store is the only strongly consistent object; everything else is derived.
- •Public swarmkit targets are on the order of tens of thousands of tasks across about a thousand nodes.
- •This answer assumes 300 workers, 5 managers, 3,000 services, 30,000 tasks unless stated otherwise.
Section Rescue Kit
Buzzwords to use:
Safe statements:
- "I will separate the desired-state store from everything that derives from it before choosing any component."
- "Let me define which decisions require quorum and which run locally on a single worker."