Skip to content

Three Tier Architecture using Docker. Create Blogging Site using WordPress, MySQL as DataBase for WordPress and Docker custom Network.

Notifications You must be signed in to change notification settings

Pratikshinde55/Docker-Three_Tier-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 

Repository files navigation

Three Tier Architecture using Docker

Create Blogging Site using Docker manual method.

  • Set-up:

I use AWS EC2 Instance for this work. The EC2 Amazon machine is Amazon-linux.

  • What is Three-tier Architecture:
  1. For Blogging Site I use "WordPress".
  2. For DataBase to the Wordpress I use "MySQL".
  3. For Network I use own customised "Docker network".

Step: 1 [Install Docker & Start Docker Services]

Launch EC2 instance and install docker inside and start docker Service:

Docker install command:

yum install docker -y 

Start Docker Service command:

systemctl enable  docker --now 

Check Docker Status:

systemctl status docker

Screenshot 2023-08-30 181908

Step: 2 [Create Custom Docker Network]

create own net name as "psnet"

Subnet range 10.0.0.1/16 in CIDR format.

Screenshot 2023-08-30 185447

Command for check docker network list:

docker network ls

Docker network create command:

docker network create --driver bridge --subnet 10.0.0.1/16  psnet

Step: 3 [Launch MySQL Container using own Network]

Create database with own driver (database- container name)...also provide required enviromental variable Screenshot 2023-08-30 185342

Launch MySQL container using custom networks & adding environmental variables & Attach Host folder(Mount volume) Default folder of MySQL storage is /var/lib/mysql:

docker run -dit --name database --network psnet -v /mydata:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=pratik55  -e MYSQL_DATABASE=mydatabase  -e MYSQL_USER=jack  -e MYSQL_PASSWORD=jack11 mysql

Inspect command for check:(here we see our Subnet range(10.0.0.1/16) to our given database container)

docker inspect database   

Screenshot 2023-08-30 185033

Screenshot 2023-08-30 185149

Here, check provided Subnet range.

Step: 4 [Launch Wordpress Container using own Newtwork]

Launch wordpress and uase PATTING to make outside world connection,As port number of container is 80.

Command for check list port numbers on system:

netstat -tnlp

Screenshot 2023-08-30 185418

Lanuch Wordpress container using custom network:

docker run -dit --name mywordpress --network psnet -p 1234:80 wordpress

Wordpress store all iformation of login with database info place in /var/www/html there is file that wp-config.php (here we can also able to attach Host folder that mount volume)

docker run -dit --name mywordpress -v /wordstorage:/var/www/html --network psnet -p 1234:80 wordpress

Can also check MYWORDPRESS has our subnet range by command on above screenshots.(step no.3)

docker inspect mywordpress

Step: 5 [Edit Inbound rule/ Firewall]

EC2 Intance has Firewall which cannot be connected by outside world, so we can modify Inbound rule(All traffic allowed)

Screenshot 2023-08-30 182129

Substeps:

  1. EC2 Dashboard
  2. Celect securtity option
  3. Go inside Security groups
  4. Select "edit inbound rule"
  5. Delete defult rule and new rule
  6. custom TCP ->> "ALL TRAFIC", ANYWHERE IPv4
  7. Save rule

Step: 6 [Access Wordpress from Browser]

Instance public + our port number that provide in wordpress contanier.

To access wordpresss from browser,need EC2 instance public IP Address+Port no. given to wordpresss container.

Screenshot 2023-08-30 182811

To get wordpress interface on google ,provide details that provided in the form of enviromental variable during "database" caintainer launch

http://65.2.146.158:1234 <<------- see interface(This site does not work as instance is terminated now)

Screenshot 2023-08-30 182954

Screenshot 2023-08-30 183151

Step: 7 [Fill Info]

Create username and password to create blog on wordpress:

Screenshot 2023-08-30 183243

Screenshot 2023-08-30 183447

Step: 8 [Create Blog page]

On Wordpress Dashboard->create Post->Add Content->Publish->Copy link and paste in the browser.

Screenshot 2023-08-30 183516

Screenshot 2023-08-30 184349

Screenshot 2023-08-30 184434

This is Three Tier Architecture using Docker Overview:

  1. WordPress-Blogging Site
  2. MySQL-Database
  3. PSNet-Own Bridge driver

About

Three Tier Architecture using Docker. Create Blogging Site using WordPress, MySQL as DataBase for WordPress and Docker custom Network.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published