Docker Swarm Basics
Docker Swarm is Docker's native container orchestration tool used to manage a cluster of Docker nodes as a single system. It helps you deploy, scale, and manage containerized applications across multiple machines.
What is Container Orchestration?
Container orchestration automates:
- Deployment of containers
- Scaling applications up or down
- Load balancing traffic
- Managing container health and failover
Key Concepts in Docker Swarm
| Term | Description |
|---|---|
| Node | A machine (physical or virtual) in the swarm |
| Manager Node | Controls the swarm and manages tasks |
| Worker Node | Runs containers assigned by manager |
| Service | Defines how containers should run |
| Task | A single running container in a service |
Initialize Docker Swarm
docker swarm init
This command turns your machine into a manager node.
Add Worker Nodes
docker swarm join --token <token> <manager-ip>:2377
Deploy a Service
docker service create
--name my-nginx
-p 8080:80
nginx
Scale a Service
docker service scale my-nginx=5
This runs 5 replicas of the container across nodes.
List Services and Nodes
docker service ls
docker node ls
Inspect and Update Service
docker service inspect my-nginx
docker service update --replicas 3 my-nginx
Remove Service
docker service rm my-nginx
Docker Swarm vs Kubernetes
| Feature | Docker Swarm | Kubernetes |
|---|---|---|
| Setup | Easy | Complex |
| Learning Curve | Low | High |
| Scalability | Moderate | High |
| Use Case | Small to medium apps | Large-scale systems |
Summary
- Docker Swarm is used for container orchestration.
- It manages multiple Docker nodes as a single cluster.
- Use
docker servicecommands to deploy and scale apps. - Best suited for simple and medium-scale deployments.
0
likes
Your Feedback
Help us improve by sharing your thoughts
Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.
Quick Links
© 2023 - 2026 OnlineLearner.in | All Rights Reserved.
