Docker Swarm: container orchestration without Kubernetes' complexity
Docker Swarm is Docker's native clustering mode that turns multiple hosts into a single virtual cluster. Unlike Docker Compose, which orchestrates containers on a single machine, Swarm distributes services across several nodes, provides high availability, built-in load balancing, and rolling updates without manual intervention. In 2026, Swarm is not deprecated, but its development has slowed in favor of Kubernetes, and its suitability depends on the size and nature of the project.
1. Swarm architecture: managers, workers, and Raft consensus
A Swarm cluster is organized into two types of nodes. Managers manage the cluster state, schedule tasks, and serve the Swarm API. Workers receive and execute the tasks assigned by managers.
Managers implement the Raft consensus algorithm to maintain a consistent state across the cluster. This means that if the leader manager fails, any of the other managers can take over task scheduling and rebalance services. Raft tolerates up to (N−1)/2 failures and requires a quorum of (N/2)+1 members. In a cluster of 5 managers, if 3 become unavailable, the system cannot schedule new tasks, although existing tasks continue to run.
flowchart TD
subgraph Swarm["Docker Swarm Cluster"]
subgraph Managers["Managers (Raft)"]
M1["Manager 1Leader"]
M2["Manager 2"]
M3["Manager 3"]
end
subgraph Workers["Workers"]
W1["Worker 1"]
W2["Worker 2"]
W3["Worker 3"]
end
S1["Web service3 replicas"]
S2["API service2 replicas"]
M1 -->|"Schedules tasks"| W1
M1 -->|"Schedules tasks"| W2
M1 -->|"Schedules tasks"| W3
M2 -.->|"State replication"| M1
M3 -.->|"State replication"| M1
S1 --> W1
S1 --> W2
S1 --> W3
S2 --> W2
S2 --> W3
end
style M1 fill:#e3f2fd,stroke:#1565c0
style M2 fill:#e3f2fd,stroke:#1565c0
style M3 fill:#e3f2fd,stroke:#1565c0
style W1 fill:#e8f5e9,stroke:#2e7d32
style W2 fill:#e8f5e9,stroke:#2e7d32
style W3 fill:#e8f5e9,stroke:#2e7d32
Practical rule for the number of managers. An odd number of managers (3 or 5) is recommended to maintain quorum. A cluster of 3 managers tolerates the loss of 1; one of 5 tolerates the loss of 2. A cluster of 2 managers offers no real redundancy, because the loss of either one breaks quorum.
2. Docker Swarm vs. Docker Compose: they are not the same
The confusion between Swarm and Compose is common because both use YAML files and share a similar syntax. But they operate at different scales.
| Dimension | Docker Compose | Docker Swarm |
|---|---|---|
| Scope | A single host | Multiple hosts |
| Architecture | Containers on the local daemon | Managers and workers with Raft |
| High availability | Depends on host stability | Node failure tolerance |
| Load balancing | Not integrated at cluster level | DNS round-robin and routing mesh |
| Rolling updates | Requires external scripts | Native docker service update |
| Secrets and configurations | Locally scoped | Encrypted distribution across the cluster |
| Scaling | Limited --scale |
docker service scale with replicas |
Compose is designed for development, testing, and single-host deployments. Swarm is designed for multi-node production, with automatic recovery and replica scheduling.
The same docker-compose.yml file can be deployed to Swarm using docker stack deploy, but not all Compose keys take effect in Swarm. Keys in the deploy section (replicas, update policies, placement constraints) only apply in Swarm mode, while keys such as build are ignored because Swarm requires pre-built images published to a registry.
flowchart LR
subgraph Compose["Docker Compose"]
C1["docker-compose.yml"] --> C2["Single host"]
C2 --> C3["Local containers"]
end
subgraph Swarm["Docker Swarm"]
S1["docker-compose.yml(deploy section)"] --> S2["docker stack deploy"]
S2 --> S3["Multi-node cluster"]
S3 --> S4["Services and tasks"]
end
style Compose fill:#e8f5e9,stroke:#2e7d32
style Swarm fill:#e3f2fd,stroke:#1565c0
3. Swarm in development: a local cluster to validate behavior
In development, Swarm does not replace Compose. Compose remains the tool for bringing up the local environment with a single command. But Swarm has a role in the validation phase before production: it allows you to test the behavior of a multi-node stack on a local machine or on a small set of virtual machines.
A typical development workflow with Swarm includes:
Build the image locally and tag it with a unique identifier. Using latest in test environments is a bad practice because the image cache can hide changes. Tagging with the Git commit hash or a timestamp is recommended.
Initialize a single-node Swarm for testing. docker swarm init turns the local host into a manager and allows deploying stacks with docker stack deploy. This is enough to validate that the Compose file is Swarm-compatible and that replicas are scheduled correctly.
Test rolling updates and rollbacks. docker service update --image new:tag service allows you to verify that the update policy configured in deploy.update_config works as expected before applying it in production.
Validate the overlay network. On a single-node local Swarm, the overlay network does not face the latency and DNS issues that appear in a real cluster, but it allows you to verify that services discover each other by name and that published ports respond through the routing mesh.
The limitation is clear: a single-node Swarm does not test fault tolerance or the behavior of the Raft quorum. That requires at least three nodes, which can be simulated with lightweight virtual machines or with containers running Docker-in-Docker.
4. Swarm in production: what works and what does not
In production, Swarm offers a set of capabilities that, for small teams and moderate workloads, remain sufficient and operationally simpler than Kubernetes.
Control plane high availability. With 3 or 5 managers, the loss of a node does not stop task scheduling. Existing services continue to run and leadership is automatically reassigned through Raft.
Rolling updates with automatic rollback. The deploy.update_config section allows you to define parallelism, delay between replicas, and the action to take if an update fails. docker service update applies the image change gradually and can automatically roll back if the healthcheck fails.
Routing mesh and load balancing. Swarm publishes ports on every node in the cluster. A request arriving at any node is redirected to the corresponding container, regardless of which node it is running on. This simplifies the configuration of external load balancers.
Encrypted secrets and configurations. docker secret and docker config distribute credentials and configuration files to services without exposing them in environment variables or in the image. Secrets are mounted as in-memory files inside the container.
Encrypted overlay networks. Overlay networks allow containers on different hosts to communicate as if they were on the same LAN. The --opt encrypted option encrypts VXLAN traffic between nodes.
flowchart TD
A["docker stack deploy"] --> B["Manager receives the stack"]
B --> C["Creates serviceswith desired replicas"]
C --> D["Scheduler distributes tasksacross workers"]
D --> E["Routing mesh publishesports on all nodes"]
E --> F["Healthchecks verifythe state of each task"]
F -->|"Failure detected"| G["Reassigns taskto a healthy node"]
F -->|"Update"| H["Rolling updateper update_config"]
style A fill:#e3f2fd,stroke:#1565c0
style D fill:#e8f5e9,stroke:#2e7d32
style G fill:#fce4ec,stroke:#c62828
style H fill:#fff3e0,stroke:#ef6c00
What does not work well in production. Swarm has no native autoscaling based on metrics. Scaling is manual (docker service scale) or through external scripts. It does not offer granular network policies comparable to Kubernetes' NetworkPolicy. The ecosystem of observability, CI/CD, and security tools is built primarily for Kubernetes, and integrations with Swarm are more limited.
A documented problem in 2026 is the incompatibility introduced by Docker Engine v29. Version 29 raised the minimum daemon API version to 1.44, which broke compatibility with clients and plugins compiled against earlier versions. V1 volume plugins, which Swarm needs for persistent storage, were rejected by the v29 daemon, and staggered upgrades between v29 and earlier nodes caused encrypted overlay network traffic to silently stop working.
5. Types of projects where Swarm makes sense in 2026
Swarm does not compete with Kubernetes for the same use cases. It has niches where its simplicity is a real advantage.
Internal tools and homelabs. A set of services across three or four VPS, managed by someone who already knows Docker, finds in Swarm a low operational ceiling and a friendly floor. It does not require learning the Kubernetes ecosystem to have replicas, rolling updates, and service discovery.
Edge deployments with limited resources. Swarm has a significantly smaller footprint than Kubernetes, even in its lightweight distributions such as k3s or microk8s. For devices with restricted resources, Swarm runs the control plane with less overhead.
Environments with strict simplicity requirements. When the specification prohibits external dependencies, Helm charts, or operators, Swarm's small surface is a feature, not a limitation. The cluster is managed with the same Docker commands the team already uses.
Containerized monoliths with simple horizontal scaling. A service with several replicas behind a load balancer is the use case Swarm was designed for. It does not need the complexity of a service mesh or advanced network policies.
Migration from Compose without rewriting the configuration. Teams that already have a working docker-compose.yml can deploy it to Swarm with minimal changes and gain high availability and rolling updates that Compose does not offer.
At the opposite end, Swarm is difficult to justify for new projects that expect to grow to dozens of services, for regulated environments that require granular RBAC and network policies, or for teams that need to hire platform engineers with experience in today's job market, where Kubernetes dominates postings.
| Scenario | Swarm | Kubernetes |
|---|---|---|
| 2-20 nodes, small team | Suitable | Overkill |
| Unpredictable workloads with autoscaling | Limited | Suitable |
| Edge with restricted resources | Suitable | Heavy |
| Multi-cloud and federation | Not supported | Supported |
| Tooling ecosystem | Limited | Broad |
| Learning curve | 1-2 weeks | 3-6 months |
6. The state of Swarm in 2026: maintained, not deprecated
The narrative that "Swarm is dead" is inaccurate. Docker Swarm mode is integrated into every current version of Docker Engine, receives bug fixes and security patches through Engine releases, and has commercial support from Mirantis with a long-term support commitment until at least 2030.
Docker Engine 29.8.0, released in September 2026, included seven specific fixes for Swarm: service name resolution after a lost membership, discovery gossip after concurrent upgrades, service creation with generated names already in use, mount ordering on forced updates, and published ports on the service mesh. The existence of these fixes indicates active maintenance, not abandonment.
However, "maintained" is not the same as "growing." Swarm's feature set has been stable for years. There is no roadmap of new capabilities comparable to Kubernetes'. Docker redirected SwarmKit development toward Kubernetes-based solutions, and Portainer, the most visible Swarm management platform, published a warning in March 2026 recommending caution to those still running Swarm and advising them to plan a gradual migration.
The conclusion is that Swarm is finished software, not abandoned software. For the use cases where it fits, it remains a reliable tool. For new projects that expect to grow, the question is not whether Swarm works, but whether the ecosystem and the job market will continue to accompany it for the life of the project.
7. The poll: what kind of project would you use Docker Swarm for?
The decision to adopt Swarm is not only technical. It depends on team size, tolerance for operational complexity, and growth expectations. We want to know the perspective of the CodeWithBotina community.
8. References
Docker Docs. (2026). Administer and maintain a swarm of Docker Engines. https://docs.docker.com/engine/swarm/admin_guide/
Docker Docs. (2024). Raft consensus in swarm mode. https://docs.docker.com/engine/swarm/raft/
Dev.to. (2026, October 16). k3s vs Docker Swarm vs Nomad in 2026. https://dev.to/dwoitzik/k3s-vs-docker-swarm-vs-nomad-in-2026-4c86
GitHub. (2026). The Complete Docker Swarm Production Guide for 2026. https://github.com/TheDecipherist/docker-swarm-guide
Middleware.io. (2026, July 2). Docker Swarm vs Kubernetes (2026): Key differences, use cases & when to use each. https://middleware.io
Portainer. (2026, March 26). Running Docker Swarm in 2026. https://www.portainer.io/blog/docker-swarm-still-works-but-does-it-still-have-a-future
SFEIR Institute. (2026, March 4). Kubernetes vs Docker Swarm: Which orchestrator to choose in 2026? https://institute.sfeir.com/en/kubernetes-training/kubernetes-vs-docker-swarm-comparison-orchestrator/
SwarmCLI. (2026, July 2). Is Docker Swarm still maintained and supported in 2026? Yes, and here is the evidence. https://swarmcli.io/blog/is-docker-swarm-maintained-and-supported-in-2026
WithRemote. (2026, May 8). Kubernetes vs Docker Swarm in 2026. https://cadence.withremote.ai/blog/kubernetes-vs-docker-swarm
Yisu. (2026, January 3). What is the difference between Docker Swarm and Docker Compose. https://m.yisu.com/zixun/1082213.html
Loading reactions...
Comments (0)
Loading session...
No comments yet. Be the first to comment.