Overview

In other technologies we have clusters, in docker, we have Swarm. Same concept, different name :)

A swarm in docker is set of servers who act as one and each server can be either: Manager or Worked. It is important to note, that manager is also a worked, but the reverse isn't so. Managers manage workers and workers obey, nothing different than clusters.

Below, you can see basic overview of the swarm:

Setup

Let's set it up. We will have 3 servers:

1 Manager

2 Workers

Automatic

You can see the automatic creation in the Vagrant section: Multiple Servers Configuration with Vagrant

After the setup is done, please be sure that workers, have joined, we can create the service as follows:

Manual

The creation of the VMs and installation of docker-ce will not be discussed as it has been done in at least 10 other sections. So let's check how to setup manager and 2 workers:

Initiation

The initiation of the Swarm is done from one of the managers as follow:

Init the Swarm

That command will initialize a swarm with 1 manager who will listen on IP: 10.100.199.200:2377 for docker swarm related activities (advertise-addr) and income traffic (listen-addr)

Manually the workers can be joined to the swarm as follows:

Add a worker to the Swarm

The token can be taken from the manager as follows:

Get Join Token for Manager & Worker

Create service

The creation of the service is rather easy: