From the course: Docker for Developers: Create and Manage Docker Containers

Initializing a swarm

- [Instructor] Getting started with Docker Swarm is easier than you might think If you've used regular Docker, enabling Swarm mode is just one command away. To do this, open your terminal and run docker swarm init. When you run docker swarm init, Docker does a few important things behind the scenes. First, it creates a new Swarm cluster. Your machine becomes the first manager node in the cluster. Then it generates a root CA and certificates. Swarm uses TLS encryption for all communication. Docker creates a certificate authority and issue certs to secure traffic between nodes. It also sets up raft for consensus. Raft is a consensus algorithm used in distributed systems. It manages replicated state machines and ensures data consistency. It also ensures that decisions like scheduling and updates are made safely and consistently. Swarm uses the Raft protocol to maintain the cluster state. Next, it assigns a unique Swarm node ID. Each node, even the first one, gets an ID that helps track it in the cluster. And finally, it provides a join token. After you run the init command, Docker gives you a token that other machines can use to join the cluster as workers. So when you run docker swarm init, you're doing more than flipping a switch. You're creating a secure, distributed system, ready to manage your containers at scale. It's a small step with a lot of power behind it.

Contents