Skip to main content

Command Palette

Search for a command to run...

Project : Containerize and Scale: Deploying Web Apps with Docker Swarm

Updated
2 min read

Objective: Discover the power of Docker Swarm, a versatile container orchestration tool, to deploy web applications with remarkable scalability, reliability, and high availability. This project showcases the seamless management and automated failover features that Docker Swarm offers, making it an ideal choice for production environments with containerized applications.

Step 1 : Create 3 EC2 instances.

Ensure that ports 2377 and 8000 are open for incoming traffic.

Step 2 : Install Docker on all instances.

Step 3 : Initialize Docker Swarm on the "swarm-manager" instance with the following command:

docker swarm init

Step 4 : After initializing the swarm on the "swarm-manager" node, a key will be generated to add other nodes as workers. Copy and run that key on the rest of the servers.

Step 5 : To check all the nodes in the manager, use the following command:

docker node ls

Step 6 : Create a service on the Manager node with this code:

sudo docker service create --name node-app-service --replicas 3 --publish 8000:8000 patelajay745/node-app-new:latest

Step 7 : Verify the running service by executing:

docker service ls

step 8 : The service will create containers on the Manager node. Check them by running:

docker ps

Step 9 : Now you can observe the Docker container running on any instance.

url : <PublicIP>:8000

Step 10 : If you wish to remove any node, execute the following command from the worker node.

By running docker node ls, you can check the node list.

That's all for this project! Embrace the power of Docker Swarm to take your web application deployment to the next level. #DockerSwarm #Containerization #Scalability #HighAvailability #DevOps #WebAppDeployment #AWS #CloudComputing #Automation

More from this blog

Ajay Patel

116 posts