100-Days-Of-DevOps-Challenge-KodeKloud

Deploy an App on Docker Containers

The Nautilus Application development team recently finished development of one of the apps that they want to deploy on a containerized platform. The Nautilus Application development and DevOps teams met to discuss some of the basic pre-requisites and requirements to complete the deployment. The team wants to test the deployment on one of the app servers before going live and set up a complete containerized stack using a docker compose fie. Below are the details of the task:

For web service:

For DB service:

After running docker-compose up you can access the app with curl command curl <server-ip or hostname>:6400/

For more details check mariadb.

Note: Once you click on FINISH button, all currently running/stopped containers will be destroyed and stack will be deployed again using your compose file.

Steps

In this daily challenge, we are going to dockerized a 2-tier application. We have to create a docker compose file bundled with frontend and database containers. let’s start…

  1. Login into App Server 2
  2. Create a docker compose file

     sudo touch /opt/itadmin/docker-compose.yml
    
  3. Copy-paste the following contents inside /opt/itadmin/docker-compose.yml

     services:
         web:
             image: php:apache
             container_name: php_web
             ports:
                 - 6400:80
             volumes:
                 - /var/www/html:/var/www/html
            
         db:
             image: mariadb:latest
             container_name: mysql_web
             ports:
                 - 3306:3306
             volumes:
                 - /var/lib/mysql:/var/lib/mysql
             environment:
                 - MARIADB_DATABASE=database_web
                 - MARIADB_USER=kkloud
                 - MARIADB_PASSWORD=your-user-password
                 - MARIADB_ROOT_PASSWORD=your-root-password
    
  4. Let’s Test

     docker compose -f /opt/itadmin/docker-compose.yml
    

It was actually a sample test, web server is not rely on db. Otherwise we had to set connection between two services.

Good to Know?

Multi-Container Applications

Two-Tier Architecture

Docker Compose Benefits

Database Configuration