---
source: https://iinventedlight.com/library/notes/docker-swarm-raft.md
title: "Docker Swarm Raft: how managers agree on cluster state"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache License 2.0 (Docker, Inc.); Apache License 2.0 (Docker, Inc.); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Raft consensus in swarm mode; Docker, Inc., Raft consensus in swarm mode (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-swarm-raft"
tags: [docker, swarm, raft, consensus, quorum]
client: Librarian
sources:
  - id: S1
    title: "Raft consensus in swarm mode"
    publisher: Docker, Inc.
    url: https://docs.docker.com/engine/swarm/raft/
    accessed: 2026-11-26
    license: "Apache License 2.0"
  - id: S2
    title: "Raft consensus in swarm mode (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/swarm/raft.md
    accessed: 2026-11-26
    license: "Apache License 2.0"
---
# Docker Swarm Raft: how managers agree on cluster state
**Answer:** Swarm managers use Raft so they share one consistent cluster state and can recover if a leader fails.

## Why Swarm uses consensus

Manager nodes run Raft to hold the global cluster state.

The goal is that every manager stores the same consistent state for scheduling work.

If the leader manager dies unexpectedly, any other manager can pick up scheduling and re-balance tasks to match the desired state.

Consensus requires a majority of nodes to agree on values when failures occur.

## Quorum and what happens on failure

Raft can tolerate up to (N-1)/2 failures and needs a quorum of (N/2)+1 members.

If 3 nodes are unavailable in a cluster of 5 managers running Raft, the system cannot process any more requests to schedule additional tasks.

Existing tasks keep running, but the scheduler cannot rebalance if the manager set is unhealthy.

Swarm mode also relies on mutual exclusion through leader election.

## See also

- [docker-swarm](https://iinventedlight.com/library/notes/docker-swarm/)
- [docker-swarm-admin](https://iinventedlight.com/library/notes/docker-swarm-admin/)
- [docker-swarm-manage-nodes](https://iinventedlight.com/library/notes/docker-swarm-manage-nodes/)

## Claims

- id: C1
  claim: Raft can tolerate (N-1)/2 failures.
  source: S1
  evidence: "Raft tolerates up to (N-1)/2 failures"

- id: C2
  claim: Existing tasks keep running when the manager set is unhealthy.
  source: S1
  evidence: "The existing tasks keep running"

- id: C3
  claim: Leader election provides mutual exclusion.
  source: S2
  evidence: "Mutual exclusion through the leader election process"

- id: C4
  claim: Managers store a consistent state.
  source: S2
  evidence: "are storing the same consistent state"

## Sources

- [S1] Raft consensus in swarm mode. Docker, Inc.. https://docs.docker.com/engine/swarm/raft/ . License: Apache License 2.0. Accessed 2026-11-26.

- [S2] Raft consensus in swarm mode (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/swarm/raft.md . License: Apache License 2.0. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Raft consensus in swarm mode; Docker, Inc., Raft consensus in swarm mode (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
