Docker _Compose_Project

Goal

Goal of this project to create Docker Compose Stack to deploy simple Java application running in Containers 3-Tier Architecture.

Pre-Requisites

  1. Create AWS EC2 Instance in Public Subnet with any desired Instance Type
  2. Allow Port 80 in Security Group
  3. Add A Record in Route 53 Hosted Zone pointing to the EC2 Public IP.
  4. Apache Maven Build Artifact (.war)
  5. Install docker and run docker service
  6. Install docker-compose
  7. Java Source Code

Docker Compose Stack

MySQL

  1. Write Dockerfile to create custom MySQL container image by taking docker.io/mysql:8.0 as reference image from Docker Hub registry.
    MYSQL_ROOT_PASSWORD
    ENV MYSQL_DATABASE
    ENV MYSQL_USER
    ENV MYSQL_PASSWORD

App:

  1. Write Dockerfile to create custom Tomcat application container image by taking docker.io/amazonlinux as reference image from Docker Hub registry.
  2. Install Apache Tomcat 8.5
  3. Install unzip, vim, telnet, mysql client, JDK 11 packages
  4. Copy .war artifact to webapps
  5. Start Tomcat services on container runtime automatically.

Nginx

  1. Write Dockerfile to create custom Nginx container image by taking docker.io/amazonlinux as reference image from Docker Hub registry.
  2. Install Nginx server
  3. Install telnet
  4. Copy custom nginx.conf file with proxy_pass rule to forward the traffic to the app container.

Compose Stack

  1. Write Docker Compose Stack to Build and Run the Nginx, MySQL, App containers.
  2. Deploy the applications into common single Bridge network
  3. Supply the values to MySQL environment variables
  4. Specify dependencies of each containers.

Validation

  1.  Run “docker-compose build” command to verify if container images are getting created
  2. Run “docker-compose up -d” command to verify if all containers are running
  3. Login to Nginx container shell and check App port is reachable
  4. Login to App container shell and check MySQL port is reachable
  5. Browse the application from public internet browser to verify the application is accessible

Destroy

  1. Once the project setup completed do not forget to clean up resources to avoid the billing for your test environment
  2. Run “docker-compose down” command to retire all containers
  3. Terminate EC2 instance from AWS Console.

Still if you are confident to deploy the compose stack, repeat the steps again. Good Luck!!

© Edwiki Trainings – Click HERE If you are interested to learn more on Cloud & DevOps stack.

1 Shares:
1 comment
  1. Hello

    hOW TO CONFIGURE THE nGINX PART CAN YOU PLEASE SUGGEST.

    i HAVE DEPLOYED app IMAGE AND db IMAGE AS A POD
    i HAVE CREATED dATABASE TABLE AND 1 ROW INSIDE THAT EPLOYEE TABLE
    i AM ABLE TO CONNECT FROM app POD TO db POD
    suppose my APP-image pod ip is 10.244.1.213

    how i will set to a poxu_Pass rule in nginx.conf
    can you please share nginx.conf

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like