Multi-tier Application.

  1. Web Tier – Where front-end application code is hosted. Front-end application is openly accessible over the internet.
    • Software Stack: Apache and PHP
  2. Database Tier – Where the application Database engine and Database is hosted. The database is only accessible from Web Tier only.
    • Software Stack: MySQL

In this architecture, we need a single server on which we need to create two Docker Container. One is for Front-End and another one is Database Container.

Step 1 : The following command will create a Docker Container with PHP and Apache. This will cover Web Tier in the server.

  • docker pull php:7.2-apache
  • docker run -d -p 80:80 –name apache-php-web-tier -v “$PWD”:/var/www/html php:7.2-apache

where apache-php-name is a Docker container name, /var/www/html is the default path to install Apache, 80:80 will point Docker Container’s 80 port with Host Machines 80 port.

Step 2 : Execute the following command on the same server to run a Docker Container with MySQL Database. This will cover Database Tier in the same server.

  • docker pull mysql
  • docker run –name mysql-db-tier -e MYSQL_ROOT_PASSWORD=Admin@Pass -d mysql

Task by trainer :

  • Launch two-tier application . use gogs as a frontend and mysql as a backend.
  • Launch MySQL image container with name “MySQL” In a detach mode. And provide required environment variables to run container.
  • Launch gogs image container with name “gogs” in a detach mode. And provide required environment variables to run container. And gogs  must be accessible through browser at port 10080.