In this article, we will see what is Docker swarm and how to create a one? With manager and worker nodes. Different operations have been applied to the containers created. After containers, we will see how to create services for those containers and assign them that.
Table of Contents
What is container orchestration?

What is Docker Swarm ?
Docker swarm is a tool for container orchestration that allows the user to manage and monitor containers. You can analyze those that have been deployed on multiple host machines.
Also, you can manage clusters of containers easily and can treat them as a single virtual machine.
There are few roles in the Docker swarm that needs your attention.
Building a docker swarm
docker swarm init --advertise-addr <manger IP>

docker swarm join --token <token id>

As I have already made a worker node from this token it is giving me the error of node already existed in the swarm, but if you run it as a new worker node it will give the message “This node joined a swarm as a worker. “
1. Docker info
If you wanted to summarize information on how many worker nodes are there in your swarm or what are the node ids and other info you can run the following command.
docker info

docker node ls

docker node rm <node-id>
docker node rm –f <node-id>


1. Creating a service
docker service create –replicas <number-of-replicas> --publish <port-mapping> <image>

docker service ls

docker service inspect --pretty <service-id>
docker service rm <service >


Conclusion
Docker swarm is an excellent resource to be able to manage multiple containers and collectively apply operations. This saves up time and effort to look at different containers running on either virtual or physical machines.