Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 38 ยท Operations and Alternatives

Docker Swarm vs Kubernetes and Other Options

Compare Docker Swarm with Kubernetes, Nomad and plain Compose on a single host: concepts, features, operations cost, and a decision guide for teams of different sizes.

Swarm is one of several ways to run containers across machines. Choosing between them is not about which is "best" but about which fits your team, your workload and your tolerance for operational complexity. This lesson compares Swarm with the main alternatives and gives a decision guide you can adapt.

Swarm cannot run on this site, so this lesson is conceptual. The runnable blocks are stand-ins: a vocabulary translator and a scoring helper that make the trade-offs explicit.

The options in one view

  • Docker Compose on one host: describes and runs several containers on a single machine. No clustering, no failover. Excellent for development and for small production setups that can tolerate a host outage.
  • Docker Swarm: clustering built into the Docker Engine. A handful of commands, one YAML format (the stack file), secrets, rolling updates, an overlay network and a routing mesh. Small feature set by design.
  • Kubernetes: a large platform with its own API, objects (Pod, Deployment, Service, Ingress, StatefulSet, ConfigMap...), extensibility (operators, CRDs), autoscaling, a huge ecosystem and managed offerings on every cloud. Powerful and more complex.
  • HashiCorp Nomad: a single binary scheduler that runs containers and also non-container workloads (raw binaries, VMs). Lighter than Kubernetes, with a different ecosystem (Consul, Vault).
  • Managed container services (cloud container platforms): you hand over the cluster and run only services; convenient, with provider lock-in.

Concepts side by side

Idea Swarm Kubernetes
Unit that runs Task (one container) Pod (one or more containers)
Desired replicas Service replicas Deployment replicas
One per node mode: global DaemonSet
Config / secrets docker config / docker secret ConfigMap / Secret
Internal load balancing Virtual IP per service ClusterIP Service
Edge traffic Routing mesh, plus a proxy such as Traefik Ingress or Gateway API
Rolling updates update_config Deployment strategy
Autoscaling Not built in HorizontalPodAutoscaler, cluster autoscaler
Stateful workloads Volumes (node-local) StatefulSet, PersistentVolumes, CSI drivers
Packaging Stack file Manifests, Helm, Kustomize
Extensibility Limited CRDs and operators
flowchart TD
  Q{"Need more than<br/>one host?"} -->|no| C["Docker Compose"]
  Q -->|yes| T{"Autoscaling, operators,<br/>big ecosystem or<br/>managed cluster?"}
  T -->|yes| K["Kubernetes"]
  T -->|no| S{"Team knows Docker,<br/>wants simplicity?"}
  S -->|yes| W["Docker Swarm"]
  S -->|no| N["Nomad or managed service"]

A rough decision path; your constraints may change the answer.

Where Swarm shines

  • Low learning curve. If you know Compose, you are most of the way there. A small team can understand the whole system.
  • Small operational footprint. No separate control plane to install; docker swarm init and you have a cluster. Fewer moving parts to patch and monitor.
  • Good defaults. Mutual TLS between nodes, encrypted secrets, rolling updates and an overlay network work out of the box.
  • A fit for modest scale. A few services across a handful to a few dozen nodes, internal tools, edge or on-premise deployments, and teams without dedicated platform engineers.

Where Swarm falls short

  • Ecosystem and momentum. Kubernetes has far more tools, cloud integrations, documentation and hiring pool. Many vendors ship only Kubernetes manifests or Helm charts.
  • No built-in autoscaling, limited scheduling features (no affinity rules beyond constraints and preferences, no priority classes).
  • Persistent storage is weaker: there is no standard volume provisioning layer comparable to CSI.
  • Extensibility: no custom resources or operators for databases and other stateful systems.
  • Future uncertainty. Swarm mode is maintained as part of Docker Engine, but it receives far fewer new features than Kubernetes. If you adopt it, check the current state of the project and plan an exit path.

Moving later

Your skills and artefacts carry over more than you might expect: containers, images, registries, health checks, 12-factor configuration, secrets-as-files and CI pipelines are identical. Tools such as Kompose can convert a Compose file into Kubernetes manifests as a starting point (you still need to review and tune the result). Keep your services stateless, configurable through environment and files, and observable, and you can migrate in either direction.

Making the decision

Ask these questions in order:

  1. Is one machine plus Compose and good backups enough? Prefer it. Complexity you do not need is a cost.
  2. Do you need automatic scaling on load, many teams sharing a platform, or operators for complex stateful software? That points to Kubernetes, ideally managed.
  3. Is your workload a mix of containers and non-container jobs? Look at Nomad.
  4. Is the team small, already fluent in Docker, and running tens of services on a few nodes? Swarm is a reasonable, honest choice.
  5. Are you required to use a vendor's platform? Then the choice is made for you.

Stand-in: vocabulary translator

Python Stand-in: Swarm words to Kubernetes words

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: a weighted decision helper

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common mistakes

  • Choosing Kubernetes because it is popular, then spending months on platform work for three services.
  • Choosing Swarm and later needing autoscaling or vendor charts without a migration plan.
  • Treating orchestration as a substitute for good application design (health checks, graceful shutdown, stateless services).
  • Comparing features and ignoring who will operate the cluster at 3 a.m.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which Swarm concept most closely matches a Kubernetes DaemonSet?

    Both run one instance on every node.
  2. 2. Which capability is built into Kubernetes but not into Swarm?

    Swarm has no built-in autoscaler.
  3. 3. A two-person team runs eight services on three nodes and knows Docker well. What is a sensible starting point?

    Simplicity matters at this size; keep services portable in case you move later.
  4. 4. What carries over when migrating between orchestrators?

    Container-level practices transfer; orchestrator manifests need translation.

Summary

  • Compose, Swarm, Kubernetes and Nomad solve different sizes of problem; there is no universal winner.
  • Swarm trades features and ecosystem for simplicity and a small footprint.
  • Kubernetes offers autoscaling, extensibility and an enormous ecosystem at higher complexity.
  • Keep services portable and decide with your team's skills and needs in mind.

Next: Project: A Complete Web Stack