Skip to content

This project contains the documentation of the implementation details for the containerizing an existing micro services application using Docker and publishing the images on Dockerhub.

License

Notifications You must be signed in to change notification settings

SumitM01/Containerization-of-a-microservice-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Containerization-of-a-microservice-application

This project contains the documentation of the implementation details for the containerizing an existing micro services application using Docker and publishing the images on Dockerhub.

Overview

The project aims to address the challenges faced by operations or DevOps teams managing multi-tier application stacks running on various platforms, including VMs, cloud environments like AWS, or physical machines in a data center. These challenges include high costs, resource wastage, human errors during deployment, and lack of synchronization across different environments. The proposed solution is to containerize the application, which can save money by using fewer resources, make deployments more reliable through the use of container images, and improve portability and reusability across environments. This approach is particularly suitable for microservice architecture. By containerizing the application, the team can achieve significant benefits and improve their operations.

Services Used

  • AWS EC2
  • Dockerhub
  • Docker Engine
  • Github

Implementation Details

Create Repositories on Dockerhub

On Dockerhub

  • Go to Repositories->Create repository-> Give a name and create.
  • In this way create 3 public repositories to host app, db and web images. Dockerhub-repos

Configure EC2 instance and Docker engine

  • Launch an EC2 instance with the following specifications:
    • Instance type: t2.small/t2.medium (higher RAM is required for proper functioning of docker engine)
    • AMI: Ubuntu 22
    • Security Group inbound rules :
      • port 22 allowed from your IP
      • port 80 allowed from your IP.
    • User data content:
    #!/bin/bash
    sudo apt-get update
    sudo apt-get install ca-certificates curl gnupg -y
    sudo install -m 0755 -d /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg -y
    sudo chmod a+r /etc/apt/keyrings/docker.gpg
    echo \
    "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
    • This will install docker engine on your instance while it is being launched. ec2-instance

Fork vprofile-project repository into your account

  • On Github
  • Fork the vprofile-project repository with the same name into your account.
  • Switch to branch containers which contains empty docker files which you can edit.

Write dockerfiles to customize images

  • Clone this repository into your machine.
  • Switch to branch containers using the command
git checkout containers

Run the files and upload images to Dockerhub

  • ssh to the ec2 instance.
  • Clone the remote repository from github.
  • Switch to containers branch.
  • Validate the changes made.
  • Run the following command to build the images:
docker compose build
  • Run the following command to see the built images:
docker images

docker-images

  • Run the following command to spin up all the containers from the images in the background:
docker compose up -d

Docker-compose-up

  • Run the following command to login to Dockerhub
docker login
- Provide username and password to login.
  • Run the following command to upload images to dockerhub:
docker push your_account_name/repository_name
  • Logout from docker hub using
docker logout

Stop the containers and clean up

  • After validation and uploading is completed perform the following commands to clean up:
docker compose down
docker system prune -y

Results

As the containers are deployed, I validated them by visiting the following pages:

  • Login Page login-page

  • Home Page home-page

Here we can see that the backend services RDS, Elasticache and RabbitMQ are also configured correctly.

  • User list page database-users-page
  • Database Validation db-validation
  • Rabbitmq status rabbitmq-start-success
  • Memcache Validation cache-validation

Conclusion

To conclude, the project provides a cost efficient way to manage infrastructure by using containers to host applications. I have successfully conatinerized the existing application using docker and uploaded the images to dockerhub for your viewing. As documented in this markdown format file, I have invested a significant amount of time in researching, learning, debugging to implement this project. If you appreciate this document please share with friends and do give it a try.

References

About

This project contains the documentation of the implementation details for the containerizing an existing micro services application using Docker and publishing the images on Dockerhub.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published