Skip to content

Containerization Process

Chichi Ugorji edited this page Jan 14, 2024 · 1 revision

Introduction

This document outlines the steps followed in the containerization of our web application. The process involves creating a Dockerfile, building a Docker image, and managing the image with Docker commands.

Containerization Steps

Creating the Dockerfile:

Base Image: Selected python:3.9-slim for linux/arm64/v8 as the base image.

Working Directory: Set /app as the working directory using WORKDIR /app. Copying Application Files: Used COPY . /app to transfer local files into the container.

Installing Dependencies: Installed necessary packages from requirements.txt using RUN pip install --trusted-host pypi.python.org -r requirements.txt. Exposing Port: Exposed port 5000 with EXPOSE 5000. Startup Command: Defined the startup command CMD ["python", "app.py"]. Building the Docker Image:

_Command: docker build -t web-delivery ._

This command builds the image from the Dockerfile in the current directory and tags it as web-delivery.

Running the Container:

Command: docker run -p 8000:5000 web-delivery

This command runs the image as a container, mapping port 5000 of the container to port 8000 of the host.

Docker Commands Documentation

Building Image: docker build -t <image-name> . builds the Docker image. Running Container: docker run -p <host-port>:<container-port> <image-name> starts a container. Tagging Image: docker tag <local-image-name> <docker-hub-username>/<image-name>:<tag> tags the image for Docker Hub. Pushing to Docker Hub: docker push <docker-hub-username>/<image-name>:<tag> uploads the image to Docker Hub.

Image Information

Image Name: web-delivery Tag: v1 Usage: The image runs a Flask web application, accessible at http://localhost:8000.

Clone this wiki locally