Voiced by Amazon Polly |
Overview
In today’s fast-paced tech landscape, deploying, scaling, and managing applications efficiently is crucial. To satisfy these expectations, containerization has become a crucial technology, encapsulating programs and their dependencies into lightweight, portable containers. Leading containerization platform Docker is becoming a standard tool for DevOps teams and engineers. Running a single container, though, is frequently only the first step. Orchestrating numerous containers over a cluster of servers is crucial for increasingly complicated applications, especially those that need to be highly available and scalable. Docker Swarm enters the picture here.
Introduction
Containerization has revolutionized the way we develop, deploy, and manage applications. Docker, a leading containerization platform, allows developers to package applications and their dependencies into containers, ensuring consistency across multiple environments. Docker facilitates the running of single containers, but a more advanced solution is needed to orchestrate numerous containers over a cluster of servers. One such technology that gives Docker containers native clustering and orchestration features is Docker Swarm. We’ll look at utilizing Docker Swarm to deploy a web application in this blog.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Docker-swarm
One virtual Docker host is created from a pool of Docker servers using Docker Swarm. It coordinates and oversees a group of real or virtual machines that serve as Docker nodes. Among the main attributes of Docker Swarm are:
- Scalability: We can add or remove containers to extend your applications horizontally.
- High Availability: This feature guarantees your application is constantly operating by automatically rescheduling failing containers.
- Load Balancing: Distributes incoming service requests among available containers using load balancing.
- Declarative Service Model: This model lets us specify the ideal condition for the services, and Swarm takes care of keeping them there.
Guide to host web application
- Installation of Docker Swarm:
- Create the 3 AWS instances with the following name: Swarm master, Swarm worker-1, Swarm worker-2
2. In all three instances, inside the inbound rules, allow
- Custom TCP — 2377 — Anywhere IPv4
- Custom TCP — 8001 — Anywhere IPv4
3. Install the Docker in all the 3 instances:
1 2 |
sudo apt-get update sudo apt-get install docker.io |
4. Open your Swarm master node’s terminal and run the command:
1 |
sudo docker swarm init |
5. Run this command in Worker instances:
1 |
sudo docker swarm join --token <SWARM_TOKEN> <MASTER_IP>:2377 |
Worker node 1:
Worker node 2:
6. To check about all the nodes in the manager, run:
1 |
docker swarm node ls |
Running Mern-Django Application using Docker Swarm
- This is the react-django-based application’s docker image, which you should use Docker Swarm to launch. To accomplish that, a Docker service must be created:
The Docker service name—in this example, “django-app-service”—is specified with the option –name django-app-service.
–replicas 3: This instructs the service to have three replicas. This indicates that Docker Swarm will create and maintain three instances of the designated container.
800-publish: 800-01: This assigns the host’s port 8001 to the service container’s port 8001. It permits external users to access the host computer’s service.
2. To see the docker services, run the below command:
1 |
sudo docker service ls |
3. At this point, this service will create the Manager node’s container. Use this command to verify:
1 |
sudo docker ps |
At this point, all three nodes will be operating this service. Simply take the IP address of any node and then port 8001 to verify this. Regarding <Any_ip_of_3_vms>:8001.
Removing the worker node
- Simply execute the following to eliminate any node from the environment:
1 |
sudo docker swarm leave |
2. As we removed one of the workers and inside the status, we can see it’s down.
1 |
sudo docker nodes ls |
Conclusion
Because Docker Swarm makes administering containerized apps easier, it’s an effective solution for providing scalable and resilient services. Use Docker Swarm to improve application stability and expedite your deployment operations.
Drop a query if you have any questions regarding Docker Swarm and we will get back to you quickly.
Making IT Networks Enterprise-ready – Cloud Management Services
- Accelerated cloud migration
- End-to-end view of the cloud environment
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, and many more.
To get started, go through our Consultancy page and Managed Services Package, CloudThat’s offerings.
FAQs
1. How can I use Docker Swarm to expand my application?
ANS: – You may scale the application by making changes to the docker-compose.yml file or by using the command docker service scale <service_name>=<number_of_replicas>.
2. Can Docker Swarm handle rolling updates?
ANS: – Indeed, Docker Swarm supports rolling updates. This means that you may update services without downtime by progressively swapping out outdated containers with new ones in line with the update settings you’ve provided.
![](https://content.cloudthat.com/resources/wp-content/uploads/2024/03/1694694663290-min-150x150.jpg)
WRITTEN BY Ritushree Dutta
Comments