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. Login the Azure portal.
    az login
  2. Click the App registrations tab and then click New Registration. Input the name for the application and click Register. A new application is created.
    Note the Application ID, Directory ID and Object ID of this application for future use.
  3. On the left pane of the Azure portal window, click Certificates & secrets. In the new window, click on New Client secret and give a name to the secret. A new secret is generated. The details of the secret will be available only at this time.
    Note: Save the Value of the secret for future use. Viewing the details of the secret will not be possible later.
  4. Download the template to create the Docker Swarm cluster from GitHub or Docker Hub. Add this template to the deployment page on the Azure portal. Input the value for Public SSH Key, Resource Group, Docker Swarm Manager and Worker count.
  5. Click Purchase located at the bottom of the template.
    The Docker Swarm cluster will created. This takes 30 to 40 minutes.
  6. Click Resource Group > Details for externalSSHLoadBalancer.
  7. Click View inbound NAT rules. Save the destination IP address and the Port Number. This will be required for connecting to the Swarm cluster.
  8. SSH into the docker Swarm Manager node using the following command.
    ssh -A -i <Private ssh Key> -p <Port Number> docker@<IP>

    The port number and the IP is same as the Port Number and IP address for the Destination recorded in Step 8. The Private shh Key is the private key of your local host.

    For example,
    ssh -A -i .ssh/id_rsa -p 50000 docker@40.114.2.176
  9. After logging into the Swarm Manager node run the following command:
    docker node ls

    A sample output for reference is:

    swarm-manager000000:~$ docker node ls
    ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
    jrsetvr1fqeirs9vghbju2gym * swarm-manager000000 Ready Active Leader 18.09.2
    v4d9vw7hq3jl837zbqtx6d0ig swarm-worker000000 Ready Active 18.09.2
  10. Navigate to the following folder:
    docker-deploy/azure/swarm/manifest-azure-swarm
  11. SSH into the machine that you will run as Swarm Manager.
  12. Login to the Docker Registry.
     docker login <registry host> -u <user> -p <password>

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

  13. 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