Creating a Docker Swarm Cluster

This procedure describes how to create a Docker Swarm cluster for on-premises Bare Metal.

Procedure

  1. Navigate to the docker-deploy/onprem/swarm/manifest-onprem-swarm folder.
  2. 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:
    • 2377 (TCP)
    • 4789 (UDP)
    • 7946 (TCP & UDP)
    If required, update your firewall rules to open these ports.
    Note: It has been observed that IPv6 does not work well with Swarm clusters. The recommendation is to use IPv4.
  3. SSH into the machine that you want to run as swarm manager.
  4. Start swarm manager on the selected node.
    1. 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.
    2. 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.
  5. 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.
    docker node ls

    Sample output:

  6. Login to the Docker registry:
    docker login <registry host> -u <user> -p <password> 
    For example:
    docker login mashbuilder-1.na.tibco.com  -u admin -p <pwd>
    Note: Ensure login is successful before proceeding.
  7. 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