Project 1: Containerization of a Two-Tier Application using Docker, Docker Compose, and Image Scanning with Docker Scout
Neamul Kabir Emon
Helping Businesses Deploy 2x Faster, Cut 40% Cloud Costs & Stay Secure | DevOps Engineer ? AWS ? Azure ? GCP ? Kubernetes ? Terraform ? CEH ? Penetration Testing | Cloud & Security Expert
Tools Required:
Overview/Description:
This project involves containerizing a two-tier application (such as a web application with a database) using Docker and orchestrating the containers using Docker Compose. The project will also include using Docker Scout to scan the created Docker images for security vulnerabilities. This will give practical experience in containerization, orchestration, and security aspects of Dockerized applications.
Code Repository:
Requirements:
Functional Requirements:
Non-Functional Requirements:
In this Project, I Successfully containerised a two-tier application using Docker and orchestrated the deployment with Docker Compose. Gained expertise in Docker image creation, and management, and performed vulnerability scanning using Docker Scout. This project enhanced my understanding of containerization, network communication between containers, and security practices in Docker environments.
Step-by-Step Deployment Guide:
git clone https://github.com/neamulkabiremon/flask-app.git
领英推荐
cd flask-app
# Use an official Python runtime as the base image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Install required packages for system
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y gcc default-libmysqlclient-dev pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container
COPY requirements.txt .
# Install app dependencies
RUN pip install mysqlclient
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Specify the command to run your application
CMD ["python", "app.py"]
version: '3'
services:
backend:
build:
context: .
ports:
- "5000:5000"
environment:
MYSQL_HOST: mysql
MYSQL_USER: admin
MYSQL_PASSWORD: admin
MYSQL_DB: myDb
depends_on:
- mysql
mysql:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: myDb
MYSQL_USER: admin
MYSQL_PASSWORD: admin
volumes:
- ./message.sql:/docker-entrypoint-initdb.d/message.sql # Mount sql script into container's /docker-entrypoint-initdb.d directory to get table automatically created
- mysql-data:/var/lib/mysql # Mount the volume for MySQL data storage
volumes:
mysql-data:
docker-compose up -d --build
Let's check if the application is running on the specified port or not.
docker-scout quickview neamulkabiremon/flask-app_backend:latest
Note: Modify the Dockerfile, docker-compose.yml, and other configuration files as per your application's requirements. Ensure to follow best practices and security measures throughout the project implementation.
Neamul, impressive work on containerizing the two-tier application! This project demonstrates a solid grasp of Docker essentials. How do you see these skills benefiting our team's future initiatives?