Prerequisites
- Six CentOS 7.6 VMs (2 vCPU, 4 GB RAM) on AWS
- Docker 19.03 installed on all nodes
- Swarm ports open (2377, 7946 TCP/UDP, 4789 UDP)
- Fully qualified hostnames and name resolution for all nodes
Verify OS and Docker:
1. Initialize the Swarm
On managerone, initialize the Swarm and advertise its IP:The
--advertise-addr flag sets the manager’s reachable IP for new nodes.2. Add Additional Managers
2.1 Retrieve Manager Join Token
On managerone:2.2 Join managertwo and managerthree
On each additional manager node:
2.3 Verify Managers
From managerone:3. Add Worker Nodes
3.1 Retrieve Worker Join Token
On managerone:3.2 Join workerone, workertwo, workerthree
On each worker:
4. Testing Manager Quorum
Docker Swarm requires a majority of manager nodes to maintain a leader.4.1 Simulate One Manager Failure
On managertwo:4.2 Simulate Two Manager Failures
On managerthree:Never simulate quorum loss in production. You will lose control over scheduling and service updates.
5. Restoring Quorum
-
Start Docker on managertwo:
- Wait for the node to rejoin (quorum 2/3 restored).
-
Start Docker on managerthree:
-
Verify:
Leader or Reachable.