Install Docker Swarm Centos 7

I, Hardware requirement & environment.

Have 2 Gib Ram free

8 Gib free space storage

Feb 17, 2020 Some of the key benefits of Docker swarm mode are container self-healing, load balancing, container scale up and scale down, service discovery and rolling updates. In last couple of articles we have discussed the followings topics. How to install Docker on CentOS 7; How to build Docker Container Images with Dockerfile. We will install Docker Swarm on CentOS 7 and create a stack for Keycloak. Note that Keycloak realm configuration is not covered in this article. Three CentOS 7 VMs with root access. Private IP address for the master node (e.g. 10.11.1.80) MySQL database and user credentials to store Keycloak configuration. Install Docker Engine.

II, Setup

The picture below illustrates how we create three-node on Virtualbox, how they connect one another and connect the internet.

Nat network is used to connect one another by three nodes.

A Bridge network is used to connect the internet and host machine to access nodes (eg: access by ssh).

Install docker swarm centos 7 free

In my case, Ip of Nodes in Nat network I will set as follow:

Node_1: 10.0.2.10

Node_2: 10.0.2.11

Install Docker Swarm Centos 7

Node_3: 10.0.2.12

1, Install nodes in the cluster, modify network config.

First of all, you need to install Virtualbox on your host machine.

Install And Configure Docker Swarm On Centos 7

Link download https://www.virtualbox.org/wiki/Downloads

After you install VirtualBox completely, we have to set up a Nat network, this Nat network is used to connect one another by three nodes.

File >> Preferences >> Network >> Add new Nat

In my case, I set up Nat network IP 10.0.2.0/24, you can change them as you need.

Next step, we create three-node and install Centos 7 on them.

After creating three-node, we will modify the network config (you need root permission).

In my case, I have two network interfaces enp0s3 (Nat network) and enp0s8 (Bridge network).

Step 1: Setup Nat network, we have to use a Static IP address, because this address is used to communicate with one another by nodes in our cluster.

Step 2: Enable Bridge network, we need only using the dynamic IP address on this network.

Set 3: Change hostname and naming rest nodes in the cluster.

Restart the guest machine. Setup two nodes (node_2, node_3) in the cluster are the same.

2, Install docker, docker swarm

Install Docker Swarm Centos 7 Download

Execute some commands in the terminal of all nodes (You need root permission).

Step 1: Install docker

Step 2: Open ports to docker nodes to communicate with one another.

Step 3: Initialize docker swarm, and join nodes in the cluster

In my case, node 1 is the master node, node 2 and node 3 are the worker nodes.

Install Docker Swarm Centos 7 64-bit

Install Docker Swarm Centos 7

Execute the above command on node_2 and node_3 to join docker node 2 and node 3 into the cluster.

CentosTorrent

When you complete install the docker swarm cluster on Virtualbox, the terminal will show something like this