Project Description
The project aims to deploy a web application using Docker Swarm, a container orchestration tool that allows for easy management and scaling of containerized applications. The project will utilize Docker Swarm's production-ready features such as load balancing, rolling updates, and service discovery to ensure high availability and reliability of the web application. The project will involve creating a Dockerfile to package the application into a container and then deploying it onto a Swarm cluster. The Swarm cluster will be configured to provide automated failover, load balancing, and horizontal scaling to the application. The goal of the project is to demonstrate the benefits of Docker Swarm for deploying and managing containerized applications in production environments.
Pre-requisites
Spin-up three servers in the AWS management console.
Two servers are worker nodes and one server is manager mode.
Install docker on all three servers.
You can follow my previous blog for server spin-up and installing docker.
linkedin.com/feed/update/urn:li:activity:70..
Project steps
Initialise the docker swarm in the manager node.
To add a worker to this swarm, run the following command as displayed after the "docker swarm init" :
"docker swarm join --token SWMTKN-1-19irxu8l190i6iofpj4qnhj600y8h2pqyqybp3pdgga5xp8y70-a1be6hvg29pkj28oax3vox6gv 172.31.92.104:2377"
Open port 2377 in the security group for all the servers.
Now join both worker nodes o the manager node.
We can check the docker swarm status to check the connected worker nodes o manager nodes.
"docker node ls"
Let's take an image from my repository to deploy the application on the docker swarm servers.
The link to my DockerHub image is as follows:-
hub.docker.com/repository/docker/bandank/fl..
Create a service in the docker manager node server to install the application through the docker image from the docker hub.
sudo docker service create --name flask-calculator --replicas 3 --publish 3000:3000 bandank/flask-calculator:latest
We can check the service that is created in the manager node server.
Also, check the docker logs in the worker node servers for running docker containers.
Open the port 3000 which is required to run the application.
Let's check the web-app in both the swarm node servers.
The application is running on both servers now.
Thanks for reading my article. Have a nice day.