Docker Swarm is a container orchestration tool that allows you to manage and scale a cluster of Docker hosts. While standalone Docker is great for running containers on a single host, Docker Swarm extends this capability to a group of machines, forming a swarm that can efficiently distribute and manage containerised applications.
In this article:
If you are looking for other deployment tutorials checkout out one of these:
- Deploy Django on Hetzner Cloud
- Deploy Django to Digital Ocean Droplet
- Deploy Django to AWS Lightsail
- Deploy Django to AWS EC2
- Deploy Django on Linode
- Deploy Django to Google Cloud Platform
If you used a regular Docker deployments, you already know the flexibility containerisation provides.
Docker Swarm is a next step in scaling your applications outside of capacity of a single server.
Docker Swarm allows you:
- Scale your application(s) horizontally – run many copies of your application;
- Scale your server resources by adding, removing or replacing servers with changing requirements and workload;
- Have servers across multiple cloud providers or regions, avoiding vendor lock;
- Add more apps to cluster without the need to worry and handle placement of containers across your servers
- Cut down costs by running on cloud providers that offer the best price for servers
Scaling applications in Docker Swarm Cluster
You can easily manage a number of containers/replicas that will be running for each process in your app.
You can scale every process of every app individually at any given time.
Compared to a standalone Docker instance, Docker Swarm allows scaling a process even in a cluster with only one server, fully utilising its resources.
How Docker Swarm Cluster works?
Docker Swarm works by turning a group of Docker hosts into a single virtual host, allowing you to manage and orchestrate containers across multiple machines.
Appliku initializes Docker Swarm on the first server in your cluster, making it a Swarm Manager.
Other machines that you add to swarm will join as worker nodes.
An Nginx server will be deployed on the first server to load balance the traffic between all containers across all worker nodes that are responding to HTTP requests.
Docker Swarm overlay network takes care of distributing the traffic and removing broken nodes from load balancing.
If a worker node fails or is disconnected, the Swarm Manager reschedules the tasks on other healthy nodes, maintaining the desired state of the services.
Every application you deploy to Managed Docker Swarm Cluster is a separate stack.
Each process in your application becomes a service in the stack.
How to install docker swarm on Ubuntu
In order to create a Managed Docker Swarm Cluster you need to provide a fresh Ubuntu 22.04 LTS server with x86 or arm64 architecture.
Appliku will install all necessary packages and configure them, including Docker.
Then docker swarm will be initialized.
If you add a server into an existing cluster then instead of initializing Docker Swarm, the server will be joined to an existing cluster.
Where are Docker Swarm logs
You can access logs of every application in the dashboard by going from Application Overview page to App Logs and selecting what process/service you want to fetch logs for.
Multi-Cloud Support in Managed Docker Swarm
You can add servers from different providers to a given cluster, this allows you to optimise costs, put servers closers to your customers and increase stability and availability of your deployed app.