Docker Project
Akshay Shinde
2 min read
1.Update Linux Packages
apt-get update apt-get upgrade
Install Docker
sudo apt-get install docker.io
Add user and give all permission
sudo usermod -aG docker $USER
Reboot
sudo reboot
Check if user is added in group
cat /etc/group
Install Git and clone repository from GitHub
sudo apt-get install git
git clone https://github.com/akshayshinde3/two-tier-flask-app.git
Enter in two-tier-flask-app repository
cd two-tier-flask-app
To Read Configuration
cat app.py
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
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
Go to the instance
click on security group
Edit inbound rules
create 5000 Port no
select anywhare-IPv4
copy the Public IPv4 address & Run on port no 5000
Successfully Completed Two-tier-app ✅
1
Subscribe to my newsletter
Read articles from Akshay Shinde directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by