1. What is Docker Swarm?
- Sharon Rajendra Manmothe

- 2 days ago
- 5 min read
What is Docker Swarm?
It helps you:
Run multiple containers
Scale containers
Distribute traffic
Provide self-healing
If Docker runs one container,
Docker Swarm manages many containers together.
Check Docker Installation
Open PowerShell / CMD / Terminal
docker --versionIf Docker is installed, you will see version output.

Initialize Docker Swarm
Now convert your machine into a Swarm Manager Node
docker swarm initWhat happens internally?
Your system becomes Manager Node
Docker creates:
Swarm cluster
Internal network
Raft database (stores cluster state)
You will see output like:
Swarm initialized: current node (xxxxx) is now a manager.
4: Check Swarm Nodes
docker node lsYou will see something like:

Your machine is now:
Manager
Leader
Active
5: Create First Service
Now we create a service using Nginx.
What is Service?
In Swarm:
We don’t create containers directly. We create services.
Service manages containers automatically.
Run:
docker service create --name myweb -p 8090:80 nginx
Explanation of command:
Part | Meaning |
docker service create | Create swarm service |
--name myweb | Service name |
-p 8090:80 | Map port 8090 (host) → 80 (container) |
nginx | Image |
6: Check Service
docker service lsYou will see:

What is 1/1?
1 desired replica
1 running replica
7: Check Running Container (Task)
docker psYou will see a container running.
Swarm automatically created it.

Step 8: Open Browser
Now open:
You should see:

That means Swarm service is working successfully
Step 9: Scale the Service
Now let’s scale to 3 containers.
docker service scale myweb=3Check again:
docker service lsNow you will see:
myweb replicated 3/3 nginxSwarm created 3 containers automatically.
Step 10: See All Containers
docker psYou will see 3 nginx containers running.

Step 11: How Load Balancing Works
Even if 3 containers are running,You still access:
Swarm automatically:
Distributes traffic
Balances load between containers
You don’t configure load balancer manually.
Swarm has built-in Routing Mesh.
Step 12: Remove Service
Now delete service:
docker service rm mywebCheck:
docker service lsIt will be empty.
All containers are automatically removed.
Step 13: Leave Swarm
If you want to stop swarm:
docker swarm leave --forceNow your machine is normal Docker again.
What You Learned in This Practical
Concept | You Practiced |
Swarm Init | Created cluster |
Node | Manager Node |
Service | Created service |
Replica | Scaled containers |
Load Balancing | Automatic |
Self-Healing | Managed by Swarm |
Difference between Kubernetes and Swarm
No | Feature | Docker Swarm | Kubernetes | Explanation |
1 | Definition | Built-in orchestration tool in Docker | Open-source container orchestration platform by Google | Swarm is part of Docker. Kubernetes is a separate powerful system. |
2 | Setup | Very simple | More complex | Swarm: docker swarm init and done. Kubernetes: needs cluster setup (minikube, kubeadm, AKS, etc.). |
3 | Learning Curve | Easy | Medium to Difficult | Swarm is beginner-friendly. Kubernetes needs more understanding of concepts. |
4 | Architecture | Manager + Worker nodes | Control Plane + Worker nodes | Kubernetes has more internal components like API server, etcd, scheduler. |
5 | Main Unit | Service | Pod | Swarm manages “services”. Kubernetes runs containers inside “pods”. |
6 | Scaling | Manual scaling | Manual + Auto scaling | Swarm: docker service scale. Kubernetes: can auto-scale based on CPU (HPA). |
7 | Load Balancing | Built-in Routing Mesh | Service + kube-proxy + Ingress | Swarm automatically balances traffic. Kubernetes needs service objects. |
8 | Self-Healing | Yes | Yes (More advanced) | Both restart failed containers. Kubernetes can reschedule pods on different nodes. |
9 | Rolling Updates | Basic | Advanced | Kubernetes supports zero-downtime updates with better control. |
10 | Networking | Simple overlay network | Advanced CNI networking | Kubernetes supports complex networking plugins. |
11 | Storage | Basic volume support | Advanced persistent volumes | Kubernetes handles storage more professionally. |
12 | Secrets Management | Basic | Strong secret & config management | Kubernetes has ConfigMaps and Secrets. |
13 | Community Support | Smaller | Very Large | Kubernetes has massive global community. |
14 | Cloud Support | Limited | Fully supported (AKS, EKS, GKE) | All major clouds support Kubernetes as managed service. |
15 | Industry Usage | Low (declining) | Very High | Most companies use Kubernetes today. |
16 | Best For | Small apps, learning | Large production systems | Swarm = simple projects. Kubernetes = enterprise systems. |
DOCKER SWARM VS KUBERNETES
When we run one container using Docker, it works fine for small applications. But in real-world projects, we need:
Multiple containers
Load balancing
Auto restart if container fails
Scaling up and down
Zero downtime updates
To manage all this, we use container orchestration tools.
Two popular orchestration tools are:
Docker Swarm
Kubernetes
What is Docker Swarm?
Docker Swarm is a container orchestration tool that comes built inside Docker.
It allows us to:
Create a cluster of machines
Run multiple containers
Scale containers
Automatically restart failed containers
Distribute traffic between containers
The biggest advantage of Swarm is simplicity.
To start Swarm, we just run:
docker swarm init
That’s it. Our machine becomes a manager node.
Swarm is easy to learn and good for beginners.
What is Kubernetes?
Kubernetes is a powerful container orchestration platform developed by Google.
It is designed to manage large-scale production applications.
Kubernetes can:
Deploy containers across many machines
Automatically scale based on CPU usage
Perform rolling updates with zero downtime
Manage secrets and configuration
Move workloads if a node fails
Integrate with cloud platforms
Kubernetes is more powerful, but also more complex.
Architecture Difference
Docker Swarm Architecture
Swarm has two main components:
Manager Node
Worker Node
Manager:
Controls the cluster
Decides where containers run
Runs containers
Swarm architecture is simple and easy to understand.
Kubernetes Architecture
Kubernetes has more internal components:
Control Plane:
API Server
Scheduler
Controller Manager
etcd database
Worker Nodes:
Run Pods (which contain containers)
Kubernetes architecture is more complex because it gives more control and flexibility.
Basic Working Unit
In Docker Swarm:We create a Service.
Example:docker service create --name myweb nginx
The service manages containers automatically.
In Kubernetes:We create a Pod (inside a Deployment).
Example:kubectl create deployment myweb --image=nginx
A Pod can contain one or more containers.
Important concept:Swarm manages services.Kubernetes manages pods and deployments.
Scaling
In Docker Swarm:
docker service scale myweb=3
This creates 3 containers.
Scaling is manual.
In Kubernetes:
kubectl scale deployment myweb --replicas=3
Additionally, Kubernetes supports auto scaling using HPA (Horizontal Pod Autoscaler).
This means Kubernetes can automatically increase or decrease pods based on CPU or memory usage.
Swarm does not have advanced auto scaling.
Load Balancing
In Docker Swarm:
Swarm has built-in routing mesh.
When you publish a port like:
-p 8090:80
Swarm automatically distributes incoming traffic between all replicas.
You do not need to configure a load balancer manually.
In Kubernetes:
Load balancing works using:
Service objects
kube-proxy
Ingress (for external traffic)
Kubernetes gives more flexible and advanced load balancing, but requires configuration.
Self-Healing
In Docker Swarm:
If a container crashes, Swarm automatically restarts it.
If you say replicas = 3,Swarm always tries to maintain 3 running containers.
In Kubernetes:
If a pod crashes, it restarts.
If an entire node fails, Kubernetes can move pods to another healthy node.
Kubernetes self-healing is more intelligent and advanced.
Rolling Updates
In Docker Swarm:
Swarm supports rolling updates.But configuration options are limited.
In Kubernetes:
Rolling updates are more controlled.You can:
Control how many pods update at a time
Pause updates
Roll back to previous version easily
Kubernetes provides more enterprise-level control.
Networking
Docker Swarm:
Uses simple overlay networking.Easy to configure.
Kubernetes:
Uses CNI plugins.Supports complex networking models.Can integrate with service mesh tools.
For small projects, Swarm networking is enough.For enterprise systems, Kubernetes networking is better.
Storage Management
Docker Swarm:
Supports Docker volumes.Basic persistent storage.
Kubernetes:
Supports Persistent Volumes and Persistent Volume Claims.Works with cloud storage like Azure Disk, AWS EBS.
Kubernetes handles storage in a more structured way.
Cloud Support and Industry Usage
Docker Swarm:
Less commonly used today
Limited managed cloud services
Kubernetes:
Industry standard
Supported by:
Azure (AKS)
AWS (EKS)
Google (GKE)
Most companies today prefer Kubernetes for production systems.
When to Use What?
Use Docker Swarm when:
You are learning container orchestration
The application is small
You need quick setup
You want simplicity
Use Kubernetes when:
Application is large
High traffic
Enterprise-level system
Need auto scaling
Need cloud integration
Simple Real-World Example
Imagine an e-commerce website.
Small startup:
3 containers
Basic load balancing
Manual scaling
Swarm is enough.
Large company like Amazon:
Thousands of containers
Auto scaling based on traffic
Zero downtime updates
Multi-region deployment
Cloud integration
Kubernetes is required.
Final Summary
Docker Swarm is simple, beginner-friendly, and easy to set up.
Kubernetes is powerful, scalable, and industry standard, but more complex.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50
Product Title
Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.


Comments