Skip to content
Tutorials Center
My learning

Topics

Docker Swarm Tutorial

Learn Docker Swarm step by step: 38 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Docker Swarm? Learn what Docker Swarm mode is, what problems an orchestrator solves, which features it offers, and how the rest of this tutorial is organized.
  2. 2 Swarm, Compose and Kubernetes Compare Docker Swarm with Docker Compose and Kubernetes: scope, features, complexity and a simple decision guide for choosing an orchestrator.
  3. 3 Setting Up a Practice Cluster Prepare machines for Docker Swarm: install Docker, choose between virtual machines and Docker-in-Docker, open the required ports and plan the node layout.
  4. 4 swarm init and join Create a swarm with docker swarm init, add workers and managers with join tokens, choose the advertise address and leave or reset a cluster safely.
  5. 5 Your First Swarm Service Create, inspect, scale and remove your first Docker Swarm service with docker service commands, and watch tasks spread across the nodes of your cluster.

Swarm Architecture

  1. 6 Managers and Workers Understand the two node roles in Docker Swarm, what managers do, the leader, how workers behave, and how to size and place manager nodes.
  2. 7 Raft Consensus and Quorum Learn how Docker Swarm managers use the Raft algorithm to agree on cluster state, what quorum means, and how to recover when too many managers fail.
  3. 8 Node Management Manage Docker Swarm nodes: list and inspect them, drain for maintenance, pause scheduling, promote and demote, add labels and remove nodes safely.
  4. 9 Swarm Security and PKI See how Docker Swarm secures a cluster by default: the built-in certificate authority, mutual TLS, certificate rotation, join tokens and autolock.
  5. 10 The Orchestrator and Reconciliation See the internal components of a Swarm manager (orchestrator, allocator, scheduler, dispatcher) and how the reconciliation loop turns services into running tasks.

Services and Tasks

  1. 11 Service Create Options A guided tour of docker service create: image, name, replicas, environment, mounts, networks, ports, update and restart flags, and how to inspect the result.
  2. 12 Replicated and Global Services Understand the two Swarm service modes: replicated services with a fixed count and global services with one task per node, plus when to use each.
  3. 13 The Task Lifecycle Follow a Swarm task from new to running to shutdown: every task state, what desired state means, how to read docker service ps and why failed tasks pile up.
  4. 14 Placement Constraints and Preferences Control where Swarm runs tasks with placement constraints, spread preferences and max replicas per node, using node attributes and labels.
  5. 15 Resource Limits and Reservations Set CPU and memory limits and reservations on Swarm services, understand how the scheduler uses reservations and what happens when a container exceeds its limit.
  6. 16 Health Checks and Restart Policies Teach Swarm to detect broken containers with health checks, control restarts with restart conditions, delays and windows, and avoid crash loops.

Networking and Overlay

  1. 17 Overlay Networks Learn how overlay networks connect containers across Swarm nodes with VXLAN, how to create, attach and encrypt them, and how ingress and docker_gwbridge fit in.
  2. 18 Service Discovery and VIPs Understand how containers find each other in Swarm: the embedded DNS server, virtual IPs, load balancing with IPVS, tasks.servicename and DNS round-robin.
  3. 19 The Routing Mesh and Published Ports Learn how the Swarm ingress routing mesh exposes a service on every node, how host mode differs, and how to front it with a load balancer and keep client IPs.
  4. 20 Network Troubleshooting and Tuning A practical guide to debugging Swarm networking: DNS, VIPs, ports, MTU, subnet clashes, ingress, stale entries, plus tuning knobs for the data path.

Secrets and Configs

  1. 21 Docker Swarm Secrets: Create and Use Them Learn what Swarm secrets are, how docker secret create works, how services read them from /run/secrets, and why secrets beat environment variables for passwords.
  2. 22 Rotating Secrets and Configs in Docker Swarm Use docker config for non-sensitive files, and learn the safe rotate pattern for immutable secrets and configs: new name, service update, remove the old one.
  3. 23 Protecting Swarm Secrets: Autolock and Hygiene Understand how Swarm encrypts Raft data, what autolock and the unlock key do, how to rotate keys, and a checklist for keeping secrets out of logs, images and Git.

Stacks and Deployment

  1. 24 Compose Files for Docker Swarm Stacks Write a Compose file that docker stack deploy understands: services, networks, volumes, secrets and configs, which keys Swarm ignores, and how names are generated.
  2. 25 The deploy Key: Replicas, Placement and Policies Master the deploy section of a stack file: replicated and global mode, placement constraints and preferences, restart policy, update_config, labels and endpoint_mode.
  3. 26 Stack Commands, Environments and Overrides Learn every docker stack command, how variable substitution and multiple -c files give you dev, staging and production variants, and common deploy flags.
  4. 27 Private Registries and Image Delivery in Swarm Deliver images to every Swarm node: docker login with --with-registry-auth, pinning digests, a registry service inside the swarm, pull failures and a release flow.

Scaling and Updates

  1. 28 Scaling Services Up and Down in Docker Swarm Scale replicated services with docker service scale and update --replicas, understand how Swarm rebalances, what limits scaling, and how to plan node capacity.
  2. 29 Rolling Updates in Docker Swarm Update Swarm services without downtime: parallelism, delay, start-first versus stop-first order, failure_action, monitor, and how to watch and tune a rollout.
  3. 30 Health Checks and Rollbacks in Docker Swarm Add HEALTHCHECK or healthcheck settings so Swarm knows when a task is ready, learn how unhealthy tasks are replaced, and use docker service rollback safely.
  4. 31 Resource Limits and Reservations in Docker Swarm Control CPU and memory for Swarm services: limits versus reservations, how the scheduler uses them, OOM kills, ulimits, and how to size a service from measurements.

Operations and Alternatives

  1. 32 Monitoring and Logging a Docker Swarm See what is happening in a swarm: docker service logs, events, node and task states, logging drivers, a global log-agent pattern and metrics with Prometheus-style tools.
  2. 33 Backup and Disaster Recovery for Docker Swarm Back up Swarm state from a manager, restore it, recover from lost quorum with --force-new-cluster, and protect volumes and data with a tested disaster plan.
  3. 34 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.

Projects and Practice

  1. 35 Project: Deploy a Complete Web Stack on Swarm Build and deploy a three-tier stack on Docker Swarm: proxy, API and PostgreSQL with secrets, configs, health checks, placement and a validated stack file, step by step.
  2. 36 Project: A Zero-Downtime Release Process Design a release process for Swarm: build once, deploy by tag, canary with a second service, watch health, roll back automatically, plus a runnable rollout simulator.
  3. 37 Project: A Swarm Capacity Planner Build a runnable capacity planner that answers how many nodes a Swarm needs, what happens when a node fails, and where reservations are too high, then apply it to real stacks.
  4. 38 Docker Swarm Practice Questions and Exercises Test your Swarm skills with scenario questions on secrets, stacks, updates, failures and recovery, hands-on exercises for a lab, and interview-style answers explained.