Skip to content

keshava2005/flask-container-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Flask Containerization Demo

This project showcases the fundamentals of containerization using a simple Python Flask web application. It’s a lightweight example built to demonstrate how a basic web service can be packaged, deployed, and executed consistently across different environments using Docker.

📦 What Is Containerization?

Containerization is the technique of packaging an application along with its dependencies, configurations, and runtime into a single executable unit called a container. Unlike virtual machines, containers share the host system’s kernel, making them much faster and more efficient.

In short: “It works on my machine” now truly means “it works everywhere.”

Docker is the tool that makes this possible. It allows you to:

Package and distribute applications seamlessly

Run the same image on any system with Docker installed

Simplify updates, scaling, and deployment pipelines

🚀 Project Overview

This repository includes:

A simple Flask app (app.py) that returns a friendly greeting

A requirements.txt file listing dependencies

A Dockerfile with image build instructions

This README providing an overview and usage guide

Once containerized, the Flask app can run anywhere — on local machines, servers, or cloud platforms — without worrying about environment setup.

🧱 Folder Structure flask-container-demo/ │ ├── app.py ├── requirements.txt ├── Dockerfile └── README.md

🐳 Building and Running the Container

Build the Docker image

docker build -t flask-container-demo .

Run the container

docker run -p 5000:5000 flask-container-demo

Access the app

Open your browser and go to http://localhost:5000

Expected output:

Hello from a Docker container!

⚙️ How It Works

The Dockerfile specifies how the image is constructed:

Starts from a minimal Python base image (python:3.11-slim)

Installs Flask and dependencies

Copies the application code into the container

Exposes port 5000 and runs the app

docker build creates a self-contained image.

docker run launches a new container instance, isolated yet lightweight.

🧩 Why It’s Useful

Containerization provides major advantages for developers and teams:

Eliminates dependency and environment conflicts

Ensures consistent behavior across systems

Speeds up deployment and scaling

Enables smoother transitions between development, staging, and production

This small Flask app serves as a clear, minimal example of how Docker streamlines software delivery and environment management.

🪴 Optional Improvements

You can extend this demo by:

Adding a docker-compose.yml for multi-service setups (e.g., Flask + Database)

Publishing your image to Docker Hub

Automating builds with GitHub Actions

Trying containerization with another framework or language

License: MIT Author: Keshava A K

Purpose: Educational project to demonstrate Docker-based containerization in action

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published