Skip to content

HADIhaid/Project-Simple-Python-Web-App-in-Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Project-Simple-Python-Web-App-in-Docker

Create a minimal Flask web app (Python) and run it inside a Docker container.

docker-flask-app/

│ ├── app.py ├── requirements.txt ├── Dockerfile └── README.md

Python app

from flask import Flask

app = Flask(name)

@app.route('/') def home(): return "Hello from Dockerized Flask App!"

if name == 'main': app.run(host='0.0.0.0', port=5000)

Dockerfile

Use official Python image

FROM python:3.10-slim

Set working directory inside container

WORKDIR /app

Copy files

COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt

COPY . .

Expose port

EXPOSE 5000

Run the app

CMD ["python", "app.py"]

In your terminal:

docker build -t docker-flask-app . docker run -p 5000:5000 docker-flask-app

Then open: 👉 http://localhost:5000

You’ll see:

Hello from Dockerized Flask App!

What I Learned

Writing a Dockerfile

Building and running containers

Exposing Flask apps with Docker

About

Create a minimal Flask web app (Python) and run it inside a Docker container.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published