Table of contents
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.
Prerequisites
Let’s Get Started with AWS First thing, head over to the AWS portal and create three new instances with specific names:
Swarm-manager,
Swarm-worker1,
Swarm-worker2.
Now, Install docker on all three servers.
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" :
Now Copy and paste this token in your worker nodes
docker swarm join --token SWMTKN-1-0mh89i4vg81rjc5qk3x4lw6rqntvrecepucmk7rrslfwpdm69n-7dtesuyur6sct1w4bske7ktv7 172.31.33.94:2377
- Open port 2377 in the security group for all the servers.
We can check the docker swarm status to check the connected worker nodes o manager nodes using "docker node ls"
Let's take an image from my repository to deploy the application on the docker swarm servers.
https://hub.docker.com/repository/docker/sompandey/notes-app/general
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 notesApp --replicas 3 --publish 8000:8000 sompandey/notes-app: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 8000 which is required to run the application.
Let's check the web-app in both the swarm node servers.
The application is running in both Master and Worker node.
Thank you for enjoying my DevOps blog! Your positive response fuels my passion to dive deeper into technology and innovation.
Stay tuned for more captivating DevOps articles, where we'll explore this dynamic field together. Follow me on Hashnode and connect on LinkedIn (https://www.linkedin.com/in/som-shanker-pandey/) for the latest updates and discussions.