Skip to content

lvthillo/python-flask-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lvthillo/python-flask-docker

Basic Python Flask app in Docker which prints the hostname and IP of the container

Docker Pulls License GitHub stars

About

Launches a Flask web server inside a Docker container. When you visit the page, it displays:

The hostname of the container is 6095273a4e9b and its IP is 172.17.0.2.

This confirms the container is running and shows key networking info -- useful for demos, testing, and learning Docker networking.

Quick Start

Prerequisites

Option 1: Pull from Docker Hub (fastest)

docker pull lvthillo/python-flask-docker
docker run -d -p 8080:8080 --name flask-demo lvthillo/python-flask-docker

Visit http://localhost:8080

Option 2: Build from source

git clone https://github.com/lvthillo/python-flask-docker.git
cd python-flask-docker
docker build -t lvthillo/python-flask-docker .
docker run -d -p 8080:8080 --name flask-demo lvthillo/python-flask-docker

Verify It's Running

# Check container IP
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' flask-demo

# Check container hostname
docker inspect -f '{{ .Config.Hostname }}' flask-demo

# View logs
docker logs flask-demo

Project Structure

python-flask-docker/
├── src/
│   └── app.py      # Flask application
├── Dockerfile       # Docker build instructions
├── requirements.txt # Python dependencies
└── README.md

Stop & Clean Up

docker stop flask-demo
docker rm flask-demo

License

MIT

About

Basic Python Flask app in Docker which prints the hostname and IP of the container

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages