> For the complete documentation index, see [llms.txt](https://ricardomol.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ricardomol.gitbook.io/notes/devops/docker/3.-swarms.md).

# 3. Swarms

## Swarm clusters

Swarm = enjambre

**A group of machines (nodes) that are running Docker and joined into a cluster.**

**Nodes:** the machines in a swarm, can be **physical or virtual.**

Docker can either run in **single-host mode** or in **swarm mode** (enables the use of swarms).

**Enabling swarm mode instantly makes the current machine a swarm manager.** From then on, Docker runs the commands you execute on the swarm you’re managing, rather than just on the current machine.

**Swarm managers** can use several **strategies to run containers** (specified in the Compose file):

* **emptiest node:** fills the least utilized machines with containers
* **global:** ensures that each machine gets exactly one instance of the specified container

**Swarm managers are the only machines in a swarm that can execute your commands**, or authorize other machines to join the swarm as **workers**. Workers are just there to provide capacity and do not have the authority to tell any other machine what it can and cannot do.

## Set up your swarm

A **swarm is made up of multiple nodes, which can be either physical or virtual machines**.

**`docker swarm init` to enable swarm mode and make your current machine a swarm manager, then run `docker swarm join` on other machines to have them join the swarm as workers**.<br>
