Creating a Docker Swarm Cluster
Procedure
- Navigate to the docker-deploy/onprem/swarm/manifest-onprem-swarm folder.
-
Prepare your swarm cluster.
The number of machines in the cluster should be determined by your requirements. All the machines should be able to communicate with others in the network. The following ports should be open or available to use by Docker on each host in order for the swarm cluster to work: If required, update your firewall rules to open these ports.
- SSH into the machine that you want to run as swarm manager.
-
Start swarm manager on the selected node.
-
Run the following command:
docker swarm init --advertise-addr <Manager IP>
This will produce an output command (starting with docker swarm join) that needs to be executed on all other worker nodes.Sample command:docker swarm init --advertise-addr 10.127.135.61
Output:Swarm initialized: current node (1qqfygb5po6r0y8vqjjceu6pj) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-5ef0r0rlhqrgw5olehorwrsmn0cz83ygnkfex8lzeixndv4av3-at5f983kuwyyiyko6hls412cu 10.127.135.61:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
-
Ssh into other nodes and run the docker swarm join command (output of step 4) and advertising node's IP. Run the following command as reference to be executed on other nodes:
docker swarm join --token <TOKEN> <Manger IP>:2377 --advertise-addr <Node IP>
Sample command based on above command output:Node Command docker swarm join --token SWMTKN-1-0xuxeo975vwq2dprcy77loazmyqqqr9muzw29yh0xvopq8398z-3zo8r2hb6o3xw51cyogz3z0k6 10.107.138.60:2377 --advertise-addr 10.107.138.62 This node joined a swarm as a worker.
-
Run the following command:
- Verify that the cluster is created successfully by running the following command on the manager. Status should be ready for all the nodes. Do not proceed until all the nodes are in active status.
- Login to the Docker registry:
-
If the swarm cluster is created successfully, create an Overlay network ml5 for the containers networking. Run the following command on manager mode:
docker network create -d overlay --attachable ml5
Copyright © 2022. Cloud Software Group, Inc. All Rights Reserved.