Docker Swarm

  A Docker Swarm is a group of either physical or virtual machines that are running the Docker application and that has been configured to join together in a cluster. ... Docker swarm is a container orchestration tool, meaning that it allows the user to manage multiple containers deployed across multiple host machines

How nodes work

Docker Engine 1.12 introduces swarm mode that enables you to create a cluster of one or more Docker Engines called a swarm. A swarm consists of one or more nodes: physical or virtual machines running Docker Engine 1.12 or later in swarm mode.

There are two types of nodes: managers and workers.

 



Docker Swarm- Setup Worker and Manager Nodes


1.  Create a 3 Nodes Cluster ( 1 for master node and other 2 are for worker nodes)

2.  Name these as master, worker01, worker02 nodes

3.  On master node run the command docker swarm init

4.  Copy the join command and run it on worker01 and worker02

5.  Run docker node ls command on master node. It should show all the nodes in active state

6.  Command  docker swarm join-token worker will give token value for worker node

7.  Command  docker swarm join-token manager will give token value for manager node

8.  Command docker info will give you swarm information as well like it is active or not

9.  Command docker swarm leave will leave the node(worker node) from the cluster and docker info will return Swarm as inactive.

11. Command docker node rm -f worker02 will forcefully remove the worker from the list .

12. Command docker node inspect worker01 will inspect worker01 node.

13. Command docker node promote worker01 worker02 will promote worker01 and worker02 as manager node.

14. Command docker node demote worker01 worker02 will promote worker01 and worker02 as worker node.

Docker Swarm- Backup and Restore

Backup

systemctl stop docker

tar -zcvf swarm.tar.gz swarm/

systemctl start docker

docker node ls

systemctl stop docker

Restore 

rm -fr swarm

tar -xvzf swarm.tar.gz

systemctl start docker


Run Below command to run docker visualizer

docker service create  --name=viz --publish=8080:8080/tcp  --constraint=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock dockersamples/visualizer


Learn more about the Docker Swarm here :




Comments

Popular posts from this blog

Terraform

Scrum Master Interview help - Bootcamp

Kubernetes