Docker Project

Docker Project

Two-tier-flask-Application

1.Update Linux Packages

apt-get update
apt-get upgrade
  1. Install Docker

sudo apt-get install docker.io
  1. Add user and give all permission

sudo usermod -aG docker $USER
  1. Reboot

sudo reboot
  1. Check if user is added in group

cat /etc/group
  1. Install Git and clone repository from GitHub

sudo apt-get install git
git clone https://github.com/akshayshinde3/two-tier-flask-app.git
  1. Enter in two-tier-flask-app repository

cd two-tier-flask-app
  1. To Read Configuration

cat app.py
  1. Create Network

#network create
docker network create twotier 

#List the Network
 docker network ls

10.To Run mysql:5.7

# Create Parent directory
mkdir volumes
# Create Child directory to store data
mkdir mysql-data
#to create cointainer 
docker run -d -v $(pwd):/var/lib/mysql --network twotier -e MYSQL_USER=root -e MYSQL_PASSWORD=test@123 -e MYSQL_DB=KYC --name two-tier-mysql mysql:5.7
# to check docker cointainer status 
docker ps
  1. To Run Backend File

#Run flask-app-file
docker run -d -p 5000:5000 -e MYSQL_HOST=two-tier-mysql -e MYSQL_USER=root -e MYSQL_PASSWORD=test@123 -e MYSQL_DB=KYC --network twotier two-tier-backend:latest
# cheack ststus
docker ps
#To inspect docker container 
 docker inspect <cointainer id 1>
 docker inspect <cointainer id 2>
#check Network
 docker network ls

After these steps we are in same Network ✅

12.Aws Ec2 Instance

Step for add port

  1. Go to the instance

  2. click on security group

  3. Edit inbound rules

  4. create 5000 Port no

  5. select anywhare-IPv4

copy the Public IPv4 address & Run on port no 5000

Successfully Completed Two-tier-app ✅