Creating a Docker Swarm Cluster (Azure Swarm)

Note: It has been observed that IPv6 does not work well with Swarm clusters. The recommendation is to use IPv4.

Procedure

  1. Navigate to the following folder:
    docker-deploy/azure/swarm/manifest-azure-swarm
  2. Ensure that all machines on the network can communicate with each other, and the ports 2376, 2377, 7946 are open on each host.
  3. ssh into the machine that you will run as Swarm Manager.
  4. Start the Swarm Manager using the following command:
    Note: Before executing this command, make sure you can ping the Swarm Manager and worker machines using their private IP.
    docker swarm init --advertise-addr <Manager Private IP> 
    				

    For example:

    docker swarm init --advertise-addr 10.127.135.61

    Example 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.
  5. ssh into the other nodes and run the following docker swarm join command (using output from step 4):
    docker swarm join --token <TOKEN> <Manger Private IP>:2377 --advertise-addr <Node Private IP> 
    				

    For example:

     docker swarm join --token SWMTKN-1-0xuxeo975vwq2dprcy77loazmyqqqr9muzw29yh0xvopq8398z-3zo8r2hb6o3xw51cyogz3z0k6 10.107.138.60:2377 --advertise-addr 10.107.138.62
  6. Verify that the cluster is created successfully by running the following command on the manager. Status should be Ready for all the nodes.
    docker node ls

    Example output:

    Important: Do not proceed until all the nodes show Active in the Availability column.
  7. Login to the Docker Registry.
     docker login <registry host> -u <user> -p <password>

    Make sure the login is successful before performing the next step.

  8. Create an Overlay network "ml5" for the containers network by running the following command on the manager node:
    docker network create -d overlay --attachable ml5