Docker Swarm Basics: A Step-by-Step Guide for Beginners
Learn how to initialize a Swarm, join nodes, deploy and scale services, and manage your containerized applications efficiently.

Nidhin B

Introduction
Docker Swarm is a powerful clustering and orchestration tool that allows you to manage and scale Docker containers across multiple nodes.
In this guide, we’ll cover the basics of Docker Swarm — including setting up a Swarm, joining nodes, deploying services, scaling, updating, and more.
Whether you’re new to Docker or looking to expand your container orchestration skills, this article will give you a solid foundation to get started with Docker Swarm.
📺 For a visual demonstration of these steps, check out this video tutorial:
Docker Swarm Basics - YouTube
Prerequisites
Before diving into Docker Swarm, make sure you have the following:
- A basic understanding of Docker concepts and commands.
- Three machines (virtual or physical): one as the manager node and two as worker nodes.
- All machines should have Docker installed.
Setting Up Docker Swarm
1. Initialize the Swarm on the manager node:
docker swarm init --advertise-addr <MANAGER_NODE_IP>
2. Join the worker nodes to the Swarm:
On each worker node, run the following command (replace <MANAGER_NODE_IP>
with the IP address of the manager node):
docker swarm join --token <TOKEN> <MANAGER_NODE_IP>:2377
3. Verify the Swarm status:
On the manager node, run:
docker node ls
Deploying and Managing Services in Docker Swarm
Deploy a service:
docker service create --name my-nginx --replicas 3 -p 80:80 nginx
List services:
docker service ls
Scale a service:
docker service scale my-nginx=5
Update a service:
docker service update --image nginx:latest my-nginx
Inspect a service:
docker service inspect my-nginx
Remove a service:
docker service rm my-nginx
Conclusion
Docker Swarm provides a simple yet powerful solution for orchestrating containers in a distributed environment.
With the ability to deploy, scale, update, and manage services across multiple nodes, Docker Swarm empowers developers and system administrators to build resilient and scalable applications.
Remember to experiment and explore additional features such as rolling updates, service rollback, and service constraints to make the most out of Docker Swarm.
Happy container orchestration! 🐳✨
References

Written by
Nidhin B
Cloud Solutions Architect @Psypher.ai
Share this article
Help spread the knowledge!