What is Docker Swarm ?

A Docker Swarm is a group of machines that work as a cluster installed with a docker engine. In docker swarm, there are two categories of nodes called manager node, worker node.  In a docker swarm, we can have at least one manager node and multiple worker nodes. The manager node is responsible for the functions of the worker node. 

What is Docker Swarm-Blog

The Docker swarm allows the user to manage multiple containers deployed across n numbers of nodes. The advantage of a docker swarm is the high level of availability of a deployed application.

How to configure docker swarm:

1. As a first part, you have to create  VM / EC2 instances for your cluster. Please note, the architecture needs at least 1 manager node and 1 worker node.

Please note, all the selected nodes should be able to connect with each other using public or private IP addresses. 

Ports should be opened  :  2376, 2377 ,7946 ,4789 

2. Install docker-engine on all nodes.

Step: 1

To update the repository system.

sudo apt-get update -y
sudo apt-get upgrade -y

Step 2:

Execute the below commands to install the necessary packages:

sudo apt-get install apt-transport-https software-properties-common ca-certificates -y

Step 3:

Install  GPG key for Docker application:

wget https://download.docker.com/linux/ubuntu/gpg && sudo apt-key add gpg

Step4:

Include the Docker Swarm repository and update the system:

sudo echo “deb [arch=amd64]

https://download.docker.com/linux/ubuntu xenial stable” >>

/etc/apt/sources.list

sudo apt-get update -y

Step 5:

Use below command to install the Docker engine:

sudo apt-get install docker-ce -y

Step 6:

Once the installation is completed, try to start the Docker and then enable it to run within the boot time.

sudo systemctl start docker

sudo systemctl enable docker

3. Login into the selected node, that need to set as manager and initialize the node as manager

docker swarm init –advertise-addr <MANAGER-IP>

MANAGER-IP : Use the manager node IP (recommend to use private IP)

Docker Swarm Explained-Blog

4. From the result, you will get a command to add the worker nodes as follows

eg : docker swarm join –token SWMTKN-1-5m0xjknsbvkjsjbv6733872s4vcs4l 192.168.0.1:2377

Run the command on all worker nodes that need to be connected with the docker swarm.

To display cluster status please use the command below.

docker node ls

docker node ls
GET STARTED WITH OUR CLOUD SERVICES

Leave a Reply