Skip to content
BENIBIX Learn

Docker Swarm

Infrastructure☸️ Container OrchestrationOrchestration Basics

Also known as Swarm Mode, Docker Swarm Mode, docker swarm init

The tool in Docker that runs containers on many machines. It joins them into one group.

Think of it like

It is like a team captain. The players are there, and the captain tells each one where to stand.

Example

A team of three already runs its app with Docker Compose. They turn on swarm mode on two servers and run three copies of the app with one command.

Why it matters

It is far smaller than Kubernetes to learn. For a few servers, it can be all a team needs.

Definition

Docker Swarm is the orchestrator built into Docker. Its proper name is swarm mode. It joins several machines that run Docker into one group, called a swarm. Some machines are managers that make the plans. The rest are workers that run the containers. It uses the same docker commands and compose files people already know.

Example code

bash
docker swarm init
docker service create --name web --replicas 3 -p 8080:80 nginx
The first line turns this machine into a manager. The second asks the swarm for three copies of a web server.
A swarm has the same shape. Managers sit at the top, and workers below run the containers.

Common mistake

Mixing it up with the old Classic Swarm. That was a separate tool, and it is no longer worked on.

Key takeaways

  1. 1
    Built in. Nothing extra to install beyond Docker.
  2. 2
    Managers and workers. Managers plan, workers run the containers.
  3. 3
    Familiar files. It reads the same compose files.