A simple Flask web application containerized with Docker to demonstrate containerization basics.
/→ Hello DevOps/health→ OK/about→ This is my Docker project
- Python 3.9
- Flask
- Docker
Follow these steps to run the app on your machine without Docker:
cd app
pip install -r requirements.txt
python app.py
Then, open your browser and go to:
http://localhost:5001
Running with Docker
Build Docker Image
docker build -t dockerized-web-app .
Run Container
docker run -p 5001:5001 dockerized-web-app
Open your browser and go to:
http://localhost:5001
Challenges & Solutions
Port conflict on 5000 → fixed by changing container port to 5001
Missing dependencies (deleted requirements.txt) → restored file and rebuilt Docker image
Adding new route /about → rebuild image, verified container
Key Learnings
Dockerfile structure:
FROM python:3.9-slim → base image
WORKDIR /app → sets container working directory
COPY app/ . → copies local files into container
RUN pip install -r requirements.txt → installs dependencies
CMD ["python", "app.py"] → default command to run container
Docker ignores files in .dockerignore to reduce image size and speed up builds
Port mapping: -p host:container
Multiple builds and container runs are needed when testing changes
How to debug containerized apps and solve common issues
Next Steps / Improvements
Add environment variables
Use a multi-stage Dockerfile for smaller image sizes
Push image to Docker Hub
Add Docker Compose for multi-service setup (e.g., app + database)
Repository Structure
dockerized-web-app/
├── app/
│ ├── app.py
│ ├── requirements.txt
│ └── ... (any other code files)
├── Dockerfile
├── .dockerignore
└── README.md