What is Docker Swarm and Why we are using it?

What is Docker Swarm and Why we are using it?

Who using Docker Containers they need orchestrate software for the production environment. Why is that? Because our apps need load balancing to return a new response. Every request is a new load for our app. This situation is being very bad every second for us. In the end, we can't receive any response from our app.‌‌

Just at this moment, Swarm comes into play. Docker Swarm can create replicas from our app and assign it to any worker machine in the cluster (A cluster is multiple machines installed Docker Engine which is the connect Swarm Network). If you have Swarm cluster and create a request to your app, firstly you'll get a response from replica 1, then replica 2, then replica 3... In this way, you have a load balancing system. From now on, your potential load value is incremented.

You can use this system for your web site, database, API, or whatever you want. By the way, Swarm is included Docker Engine installation. You just type

docker swarm init

to activate the Swarm cluster. You can use Swarm cluster on only one network. If you have multiple IP addresses don't worry, Docker CLI redirects you to the right command.

When you activate the Swarm cluster you'll see a command on your terminal. This command used to add a machine to your cluster as a worker. Because when you activate the Swarm, your machine became a master node. This node has every permission on the cluster. If you wanna add another machine to the cluster as a master node you just type this command and the command redirects you to the right command

docker swarm join-token master

I almost forgot. You have options to create a cluster and manage it. Please search for Kubernetes.