Module 12: Orchestration Introduction
Why this module?
Until now, we’ve been running containers individually with Docker. But in real-world production, we often need:
Multiple containers working together.
Scaling containers up or down depending on demand.
Automatic recovery if a container fails.
Load balancing between multiple replicas.
This is where container orchestration tools like Docker Swarm and Kubernetes come in.
🔹 Why Docker Swarm / Kubernetes?
Imagine running 100+ microservices manually with just docker run. Managing them would be a nightmare.
Orchestration platforms solve this by:
Automating container scheduling across nodes.
Ensuring high availability & fault tolerance.
Handling service discovery & networking.
Supporting rolling updates and rollbacks.
💡 Docker Swarm is built into Docker, simple to start with.
💡 Kubernetes is the industry standard for large-scale container orchestration.
🔹 Basics of Container Orchestration
At a high level, orchestration platforms handle:
Cluster Management – Multiple machines (nodes) act as one big system.
Desired State Management – You declare how many replicas/services you want; the orchestrator ensures that’s always true.
Scaling – Add or remove replicas with a single command.
Self-Healing – If a container crashes, it’s restarted automatically.
Networking – Services can discover and talk to each other easily.
🔹 Running Services with Docker Swarm
Let’s do a hands-on example:
1️⃣ Initialize a Swarm cluster
docker swarm init
This makes your machine the manager node.
2️⃣ Deploy a service
docker service create --name web -p 8080:80 nginx
Creates a service named web
Runs an nginx container exposed on port
8080
3️⃣ Scale the service
docker service scale web=5
Now you have 5 replicas of the nginx container running
Swarm balances traffic between them automatically
4️⃣ Check running services
docker service ls
docker service ps web
5️⃣ Update the service
docker service update --image nginx:1.25 web
- Swarm performs a rolling update without downtime.
🔹 Preparing for Kubernetes
Docker Swarm is great for small-to-medium setups, but in enterprise-scale environments, Kubernetes dominates because of:
Stronger ecosystem (Helm, Operators, Service Mesh).
Better scaling & resilience.
Cloud provider support (EKS, AKS, GKE).
