Docker Swarm Auto-Clustering and Scaling with PaaS Power Armor

| March 28, 2018

Docker Swarm Auto-Clustering

The so-called swarm cluster represents a set of Docker Engine nodes that are run in a swarm mode to constitute a fault-tolerant platform for application hosting with built-in cluster management features. It helps to keep your dockerized services constantly running and available through distributing the workloads across different servers and data centers. Moreover, by its original implementation, Docker swarm provides such extra benefits as automatic disaster recovery, zero-downtime updates, etc. But at the same time, running such a cluster of Docker nodes could be fraught with some difficulties as this technology is rather new and thus still requires considerable system administrator’s efforts for its handling.

That’s why, in today’s article, we will describe how to avoid the complexity of manual swarm building and maintenance with a dedicated Docker Swarm Cluster package for one-click installation. This solution allows setting up a ready-to-go dockerized cluster of the required size in a matter of minutes. So, let’s go on and dive into the specifics of its realization and usage.

To get a full understanding of the described below solution, we recommend to get acquainted with the following articles on Docker Engine implementation first, as it represents a fundamental Docker Swarm component:

Docker Swarm Cluster Topology Specifics

In accordance with the original swarm cluster implementation, structure of the environment you’ll get upon installation of the package is composed of two layers (node groups) with the following prescribed roles:

  • Manager - maintains the desired state of your swarm and all of the services that are run on it
  • Worker - receives and executes tasks, that are dispatched from Manager node(s)

During installation, you can declare the desired number of containers for each layer (so-called “replicas”) and choose one of the available installation types:

  • setting up a bare cluster to subsequently deploy the required Docker image manually
  • create a swarm with the already deployed image based on the provided compose file 

By default, each node has a pre-allocated room of resources for growth upon the necessity (up to 8 GiB RAM per container). At the same time, you always pay only for the actually consumed capacities due to the pay-per-use Jelastic pricing approach.

Herewith, cluster memory consumption in idle mode is less than 128 MiB (1 cloudlet) per container, which is charged accordingly to your hosting provider pricing. This way, a reliable Docker swarm cluster of 8 nodes can be hosted for a price of just 8 cloudlets!

Docker Swarm consumption

As an additional benefit of your swarm cluster hosting at Jelastic PaaS, all containers are equally automatically distributed across the available at a platform host nodes (i.e. physical servers) to ensure extra high availability of your application.

Docker Swarm distribution across host nodes

Before installing this package, please consider the following points:

  • The chosen platform should contain environment region(s) with native Docker container support enabled. You can check a list of the supported providers via the link.
  • The included option of public IP attachment to the manager nodes is provided for billing users only.

Swarm Cluster Load Alerts & Scaling

Another significant advantage of the Docker Swarm Cluster package by Jelastic stands for convenient resource consumption statistics tracking, which allows automatic notification about load spikes or drops.

1. By default, the cluster is provided with load alerts that notify you via email about high consumption of some resource (CPU, RAM, network, etc.):

Docker Swarm load alerts

They help to keep you up-to-date with the cluster state and swiftly respond in case of any issues or necessity to enlarge capacities.

2. If you need to provide additional resources for the cluster, you can enlarge the vertical scaling limit (32 cloudlets by default) or add new nodes into the swarm. Both actions can be configured via topology wizard:

Docker Swarm scaling

Herewith, to take advantage of swarm mode’s fault-tolerance features, Docker recommends implementing an odd number of manager nodes according to your organization’s high-availability requirements.

3. Also, you can pre-configure the automatic horizontal scaling of both manager and worker nodes, which is executed based on the current cluster load. For example, scaling can be performed according to the following conditions:

  • add node(s) if RAM or CPU usage is >70% for at least 5 minutes
  • remove node(s) if RAM or CPU usage is <40% for at least 5 minutes

Docker Swarm automatic horizontal scaling

In order to keep the odd number of managers, it is recommended to scale the layer by pairs of nodes.

4. Also, to achieve additional high availability and failover protection for Docker services that you’d like to run, you can manually attach nodes from different environment regions or even installations to your swarm cluster. All the required information was sent to you via the appropriate email after the cluster installation.

Docker Swarm cluster installed

We’ve already considered the appropriate Docker Engine Inclusion into Swarm Cluster procedure in one of our articles.

Docker Swarm Installation

The Docker Swarm installation from Jelastic Marketplace is fully automated and requires just a few simple steps.


  • Free trial installation is available at Jelastic service providers from Switzerland: Flow App Engine and Hidora. Follow the link to get started at one of them
  • A set of other providers in different locations offers Docker Swarm within full billing accounts. Choose the one you require and proceed to installation using this link

If you are already registered at one of the mentioned above Jelastic service providers, you can start the installation from your dashboard.

1. Click the Marketplace button at the top of the dashboard pane and search for the Docker Swarm Cluster solution within the opened window.

Docker Swarm marketplace

Hover over the appropriate plank and click Install to continue.

2. In a second, the installation frame will be opened.

Docker Swarm installation

Here, you need to tune some details to get the cluster you need:

  • Docker Version - version of the Docker Engine CE image
  • Manager Nodes - an odd number of manager nodes to be included in a cluster (with public IP being automatically attached to each container)
  • Worker Nodes - number of worker nodes to be included in a cluster
  • choose deployment type:
    • Clean Cluster - to create a bare cluster; as an extra option, you can simultaneously install the Portainer management UI with Let’s Encrypt SSL certificates for convenient operating with cluster nodes

Docker Swarm clean cluster

    • Deploy Stack YML - to perform the docker stack deploy operation after the cluster creation and instantly install the required dockerized services specified in the appropriate compose YML file:

Docker Swarm YML deploy

  • Environment - a name for your environment
  • Display Name - optional alias to be displayed for environment
  • Region - preferred environment region (if multiple ones are available)

As an example, we’ll create a bare Docker swarm cluster with 3 manager, 5 worker nodes, and Portainer UI with Let’s Encrypt SSL. So, once all the required configurations are stated, click Install and wait for a few minutes for Jelastic PaaS to automatically perform all the necessary actions.

3. After your cluster is deployed, the corresponding environment will appear on the dashboard.

Docker Swarm environment

Next, in order to start working with your cluster, you need to access any of its manager nodes - below, we’ll discover the ways this could be accomplished.

Docker Swarm Connection

After the successful installation, your cluster can be accessed in the following ways for further management:

  • Portainer UI

In case you’ve installed a clean cluster with the Portainer UI & Let’s Encrypt SSL, the appropriate management panel can be accessed by simply opening your environment in a browser via HTTPS (the 443 port).

Docker Swarm Portainer

Note: By default, connection to Portainer is secured with a testing Let’s Encrypt SSL certificate, thus you might be shown the warning that it’s not trusted by your browser. This does not actually affect the Portainer functionality – you just need to confirm you do want to access the requested page.

Docker Swarm certificate

The required actions could differ depending on a used browser – for example, in Google Chrome, you’ll need to expand the Advanced section and click on the Proceed to {env_URL} link.

The appropriate authentication credentials to enter the Portainer itself can be found within the corresponding email notification you’ve received after the Docker swarm creation.

  • SSH Gate

Use Jelastic SSH Gate to connect to one of the Manager nodes within your Docker swarm environment to start managing the whole cluster. You can establish an SSH connection to the required container directly via the dashboard by clicking on the Web SSH button.

Docker Swarm ssh gate

An alternative option is to connect via any preferred SSH client (you’ll need to upload your public key to the dashboard).

Custom Domain & SSL Protection

Before rolling out to production with your Docker swarm cluster, you definitely need to bind a custom domain name for your application and to protect this domain with a trusted SSL certificate.

Note: The Let’s Encrypt SSL certificate installed alongside the Portainer UI is suitable for that particular service only (not for the whole environment).

1. You can review and fulfill the requirements to add SSL protection by clicking the Change Environment Topology button for the required environment (i.e. your Docker swarm cluster).

Docker Swarm change topology2. Within the opened wizard, switch to the SSL section. Here, you can see the pre-requirements of the custom SSL configuration for the environment.

Docker Swarm enable ssl

Click the Enable button to make the required adjustments automatically and Apply these changes.

3. In a minute, a load balancer node with an external IP address will be added to the environment, allowing to add a custom domain name. Follow the linked guide to view an example of how to:

  • purchase a custom domain for your application
  • configure DNS record to point from this domain to your Jelastic environment

4. Now, you can proceed with the SSL configuration. Herewith, two options are available:

After these manipulations, your Docker swarm cluster will be ready for production. If you want to learn the basics of the services and applications deployment to the swarm cluster, follow the linked guide.

This concludes our article - creating and connecting a swarm cluster with Jelastic PaaS is that simple! Try it out right now and get your reliable and highly scalable cluster with access to native Docker functionality.

As always, feel free to ask for help from our technical experts at Stackoverflow in case you have any questions on your Docker swarm cluster hosting.