Help

Configuration Guide

How to Set Up Docker Swarm HA for Monofor Products

Updated 20 Nov 2026 13 min read

How to Set Up Docker Swarm HA for Monofor Products

Runbook – Monosign + Monosync + Monopam | Node Addition, Manager Join and Deploy

NODE-1

NODE-2

NODE-3

Leader / Manager

Reachable / Manager

Reachable / Manager

Key principle: Do not run docker swarm init on new nodes. Node-2 and Node-3 join the existing cluster with the manager token.

Monofor Docker Swarm HA Architecture

Monofor products (Monosign, Monosync, Monopam) run on Docker Swarm. The installation is first performed on a single server, and the Swarm cluster is created on this server. This server becomes the main node and takes the cluster’s Leader / Manager role.

Why 1, 3 or 5 Nodes?

As recommended by Docker, the number of manager nodes is planned as an odd number. Swarm managers work with the Raft protocol, and a majority of managers (quorum) must be up for the cluster to be manageable. Therefore, 1, 3 or 5 servers are requested from the customer.

Number of nodes

Quorum (majority)

Tolerated loss

Use case

1

1

0 nodes

Single-server installation, no HA

3

2

1 node

Standard HA installation

5

3

2 nodes

Higher availability / scenarios including DRC

How Is the HA Structure Built?

In an HA installation, the product is installed only on the main node. The other nodes (Node-2, Node-3) join the existing Swarm cluster as managers with the manager join token obtained from the main node. After the join, when the stack is deployed, Swarm automatically distributes the services across all nodes.

DRC Scenario

If the customer plans a DRC (disaster recovery) environment, the servers on the DRC side are brought up in the number of nodes the customer requires. These servers go through the same pre-checks and preparation steps, and then join the main HA cluster as managers.

Caution: After the DRC nodes are added, the total number of managers must still be odd. The location holding the majority of managers determines whether the cluster can keep its quorum when an entire location is lost. Design the DRC with this in mind.

Basic Requirements

For the HA structure to work properly, check that the following conditions are met on all nodes before starting the installation:

  • All machines must be able to communicate with each other (including the Swarm ports).

  • All machines must resolve the same DNS records and get the same results.

  • All machines must have access to the same database.

  • Time settings (NTP / timezone), firewall settings and required packages listed in the Monosign requirements must be ready on all servers in advance.

End-to-End Installation Flow

  1. Pre-checks are performed on all nodes (network, DNS, DB access, time, firewall, packages).

  1. Monofor is installed on the main node and the Swarm cluster is created there.

  1. The entire /opt/monofor directory and the /etc/profile.d/monofor-env.sh file on the main node are copied to the other nodes with exactly the same file and directory paths (SCP; if a custom SSH port is used, e.g. -P 2222).

  1. Monofor images are pulled on the other nodes with the images scripts.

  1. The manager join token is obtained on the main node, and the other nodes join the cluster as managers with this token.

  1. docker stack deploy commands are run on the main node.

  1. Swarm automatically distributes the services to the nodes; the cluster and service status are verified.

Recommendation: Deploy commands can be run from any manager node; however, we recommend running the deployment from the main node.

1. Pre-Installation Checks (All Nodes)

Perform the following checks on all nodes, including the main node, before starting the installation and file transfer. Replace the IP, FQDN and port values in the examples according to the customer environment.

1.1 Communication Between Nodes and Swarm Ports

Test access from each node to the other nodes with ping and nslookup:

ping -c 3 NODE_IP

nslookup NODE_FQDN

Expected: ping must respond and nslookup must resolve each node’s name to the correct IP address. Perform this check for all node pairs (Node-1 ↔ Node-2, Node-1 ↔ Node-3, Node-2 ↔ Node-3).

For Swarm to work, the following ports must be open in the firewall between the nodes:

Port

Protocol

Purpose

2377

TCP

Cluster management (manager communication, join)

7946

TCP + UDP

Discovery and communication between nodes

4789

UDP

Overlay network traffic (monofornet)

On systems using firewalld, the ports can be opened as follows:

firewall-cmd --permanent --add-port=2377/tcp

firewall-cmd --permanent --add-port=7946/tcp

firewall-cmd --permanent --add-port=7946/udp

firewall-cmd --permanent --add-port=4789/udp

firewall-cmd --reload

Note: Also make sure the application ports in the Monosign requirements are open. If the firewall rules are managed by the network team, confirm the definitions separately.

1.2 DNS Resolution

Resolve all FQDNs used by the application (Monosign, Monopam, DB host, etc.) on each node:

cat /etc/resolv.conf

nslookup APPLICATION_FQDN

getent hosts APPLICATION_FQDN

Expected: All nodes must resolve the same DNS records and return the same IP addresses.

1.3 Database Access

Test access to the application database from each node. The DB host and port information is in monofor-env.sh and the product configuration files.

nc -zv DB_HOST DB_PORT

Expected: The connection to the same database must succeed from all nodes (succeeded / open). Since services can run on any node, even a single node that cannot reach the DB will cause service errors.

1.4 Time and NTP Settings

timedatectl

chronyc tracking

Why?: A time difference between Swarm nodes can cause problems in log correlation and in the behavior of application services. NTP must be synchronized on all nodes (System clock synchronized: yes) and the timezone must be the same.

1.5 Required Packages and Check Script

Download the installation script and run the check command. The check output shows whether the packages expected by Docker and the product are installed.

curl -SL https://download.monofor.com/install/latest/monofor.sh (opens in a new tab) \

  -o /tmp/monofor.sh && chmod +x /tmp/monofor.sh && cd /tmp

./monofor.sh -check

Also check Docker:

docker --version

systemctl is-active docker

Critical: If any of the pre-checks fail, do not proceed with the installation or the join. Resolve the missing requirement first.

2. File and Cluster Check on the Main Node

After the Monofor installation on the main node is complete, verify that the correct files and folders exist. This server is the Leader / Manager node of the existing Swarm.

ls -l /etc/profile.d/monofor-env.sh

ls -ld /opt/monofor

 Optionally, check the file structure under /opt/monofor:

find /opt/monofor -maxdepth 2 -type f | sort

 Then check the Swarm, network, stack and service status:

docker info --format '{{.Swarm.LocalNodeState}}'

docker node ls

docker network ls

docker stack ls

docker service ls

Expected: Swarm must be active. The main node must appear as Leader in the docker node ls output. The monofornet network must appear with overlay and swarm scope.

 3. Test SSH Access from the Main Node to the New Node

Verify network and SSH access before transferring files. This way you avoid connection-related problems while transferring the actual files.

ping -c 3 NODE_IP

ssh monoforha@NODE_IP

If the SSH service runs on a custom port (e.g. 2222), specify the port:

ssh -p 2222 monoforha@NODE_IP

If you can log in with SSH, the connection is fine. To exit:

exit

4. Run a Small SCP Test

Before transferring the actual /opt/monofor folder, test SCP with a small file.

echo test > /tmp/test.txt

scp /tmp/test.txt monoforha@NODE_IP:/tmp/

If a custom SSH port is used (in scp the port parameter is given with an uppercase P):

scp -P 2222 /tmp/test.txt monoforha@NODE_IP:/tmp/

 On the new node:

cat /tmp/test.txt

Expected: If the output is test, file transfer over SSH is working properly.

5. Transferring monofor-env.sh and /opt/monofor

Now transfer the actual installation files from the main node to the /tmp directory of the new node.

scp -p /etc/profile.d/monofor-env.sh monoforha@NODE_IP:/tmp/

scp -r /opt/monofor monoforha@NODE_IP:/tmp/

If a custom SSH port is used:

scp -P 2222 -p /etc/profile.d/monofor-env.sh monoforha@NODE_IP:/tmp/

scp -P 2222 -r /opt/monofor monoforha@NODE_IP:/tmp/

 The /opt/monofor folder is not just a single config file. It contains Monosign, Monopam and Monosync YAML/ENV files, images scripts, the load balancer, LDAP/RADIUS and other product files, so it is safer to transfer the folder as a whole. The files must be in exactly the same paths on the new node as on the main node.

Important: monofor-env.sh may contain sensitive information such as DB passwords, API keys and OAuth secrets. Mask these values when sharing screenshots or documents.

 6. Move the Files to Their Actual Locations on the New Node

Connect to the new node with SSH:

ssh monoforha@NODE_IP

 Switch to the root user:

su -

 Move the files to their actual locations:

cp /tmp/monofor-env.sh /etc/profile.d/monofor-env.sh

rm -rf /opt/monofor

mv /tmp/monofor /opt/monofor

Note: If you are already the root user on the new node, you do not need to use sudo.

 7. Ownership and Environment Check

If the owner of the /opt/monofor folder on the main node is root:root, apply the same ownership on the new node.

chown -R root:root /opt/monofor

ls -ld /opt/monofor

ls -l /etc/profile.d/monofor-env.sh

Load the environment file into the current shell:

source /etc/profile.d/monofor-env.sh

Check the Monosign and Monopam installation flags:

echo $msignIsInstalled

echo $mpamIsInstalled

Expected: The variables of the installed products must return yes. This shows that the environment file has been loaded correctly.

8. Pull Monofor Images on the New Node

After the file transfer is complete, pull the Monofor images on the new node. The images scripts come with the installation files transferred from the main node; run the commands as root in the directory where the scripts are located.

First pull the Monofor base images (always run):

bash images-mfor.sh

Then pull the related product images according to the image tag values in monofor-env.sh:

Variable

Condition

Command to run

msignImgTag

If the value has changed

bash images-msign.sh

msyncImgTag

If the value has changed

bash images-msync.sh

mpamImgTag

If the value has changed

bash images-mpam.sh

 Verify that the images have been pulled:

docker images

Why?: Swarm can place services on any node. If the images are not ready on a node, there may be delays or errors when a task starts on that node. Therefore, images must be pulled on every node before the join and the deploy.

 9. Get the Manager Join Token

Get the join command from the current Leader / Manager node. Since Node-2 and Node-3 will also be managers, the manager token is used, not the worker token.

docker swarm join-token manager

 The command returns an output similar to this:

docker swarm join --token SWMTKN-1-... MAIN_NODE_IP:2377

Security: The join token is confidential. Do not leave the token visible in screenshots or documents. If needed, rotate it after the process is complete.

 10. Join the New Node as a Manager

Run the join command generated by the main node on the new node.

docker swarm join --token SWMTKN-1-... MAIN_NODE_IP:2377

 After a successful join, you should see the following message:

This node joined a swarm as a manager.

Critical: Do not run docker swarm init on Node-2 or Node-3. init creates a new Swarm; the goal is to join the existing Swarm.

 11. Verify the Cluster After the Join

Return to the main node and check the cluster status:

docker node ls

Expected in the intermediate two-node state:

Node-1     Ready    Active     Leader

Node-2     Ready    Active     Reachable

 Target view after the third node is also added:

Node-1     Ready    Active     Leader

Node-2     Ready    Active     Reachable

Node-3     Ready    Active     Reachable

 The Leader here is the currently elected management node. The other nodes shown as Reachable are also managers and part of the manager quorum.

monofornet: When the new node joins the same Swarm, monofornet in overlay / swarm scope is available at cluster level. Do not run docker network create monofornet separately on the new node.

 12. Repeat the Same Flow for Node-3 (and Other Nodes, If Any)

Apply the preparation, file transfer, image pull and manager join steps you performed for Node-2 to Node-3 in the same order. The same flow applies to the other nodes in 5-node or DRC setups.

  • Perform the pre-checks: network / Swarm ports, DNS, DB access, NTP, check script.

  • Test SSH and SCP access.

  • Transfer the monofor-env.sh file.

  • Transfer the entire /opt/monofor folder.

  • Match the ownership to the main node with root:root.

  • Source the environment file and check the flags.

  • Pull the images with the images scripts.

  • Join the existing Swarm with the manager join token.

  • Verify the Ready / Active / Reachable status with docker node ls.

13. Stack Deploy from the Main Node

After all nodes have joined the cluster, run the deploy commands. Deploy can be performed from any manager node; we recommend the main node. Run the commands as root in the directory where the YAML files are located.

13.1 Monofor (Load Balancer) Stack

First deploy the Monofor base stack:

docker stack deploy -c monofor.yml monofor --detach=true

docker service update monofor_loadbalancer --force

 Then deploy the stacks of the products whose images you pulled.

13.2 Monosign

docker stack deploy -c monosign.yml monosign --detach=true

docker service update monosign_mq --force

docker service update monosign_cache --force

docker service update monosign_seed --force

docker service update monosign_api --force

docker service update monosign_service --force

docker service update monosign_account --force

docker service update monosign_management --force

docker service update monosign_access-gateway --force

docker service update monosign_ldap-gateway --force

13.3 Monosync

docker stack deploy -c monosync.yml monosync --detach=true

docker service update monosync_cache --force

docker service update monosync_service --force

docker service update monosync_ui --force

13.4 Monopam

docker stack deploy -c monopam.yml monopam --detach=true

docker service update monopam_cache --force

docker service update monopam_app --force

docker service update monopam_cdn --force

13.5 Monofor Restart

Finally, run monofor-restart:

bash monofor-restart

Note: Only deploy the stacks of the products installed in the customer environment. For example, if Monosync is not installed, skip step 13.3.

Expected: After the deploy, Swarm automatically distributes the services to the nodes. The docker stack ls output must show monofor and the installed product stacks.

14. Service Distribution and Network Checks

You can view the cluster services on any of the manager nodes:

docker stack ls

docker service ls

docker network ls

 Check that the REPLICAS column of the services has reached the desired number (e.g. 1/1, 3/3). To see on which nodes the tasks of a specific service are running:

docker service ps monosign_service

 docker ps only shows the containers actually running on that node. A node may show an empty or short docker ps list; this alone is not a problem. The Swarm scheduler distributes tasks across the nodes on its own.

15. HA Test After Installation

After all manager nodes are added and the deploy is complete, test the HA behavior of the installation not only at cluster level but also at service level.

docker node ls

docker service ls

docker service ps monosign_service

 During a planned test, it is safer to drain a node in a controlled way first instead of shutting it down:

docker node update --availability drain NODE_NAME

 Observe whether the tasks move to the other nodes. Verify that the Monosign and Monopam interfaces remain accessible.

After the test, set the node back to Active:

docker node update --availability active NODE_NAME

Note: Node shutdown / drain tests in the customer environment must be performed during a planned maintenance window and with the knowledge of the related teams.

 16. Manager Token Rotation

If the manager join token was shared openly in a screenshot or elsewhere, you can rotate it after the process is complete.

docker swarm join-token --rotate manager

 This does not remove the existing manager nodes from the cluster; it only changes the manager join token to be used from now on.

17. Quick Customer Checklist

Step

Check

Status

01

Communication between all nodes and Swarm ports (2377, 7946, 4789) open

02

DNS resolution identical on all nodes

03

Database access successful from all nodes

04

NTP / timezone consistent on all nodes

05

Check script (monofor.sh -check) successful, required packages ready

06

Main node installation complete, Swarm active / Leader

07

SSH access successful (custom port if needed)

08

SCP test successful

09

monofor-env.sh transferred

10

/opt/monofor transferred to the same path

11

Ownership root:root checked

12

Environment sourced, flags checked

13

Images pulled with the images scripts

14

Joined with the manager token

15

docker node ls: all nodes Ready / Active / Reachable

16

Same steps repeated for the other nodes

17

Stack deploy performed from the main node, monofor-restart run

18

docker service ls: replicas at the desired number

19

HA / drain test performed in a controlled way

Permanent link