π³ Build a Tiny Flask Web App in Docker (with Ports)
docker run -p 8080:5000 flask-hello
Then open in your browser: http://localhost:8080
Step 6: Stop the container
Press Ctrl + C in the terminal.
Quick Troubleshooting
-
Browser says “This site can’t be reached”:
Make sure the container is running and you used the
-pport mapping. -
Flask runs but not accessible:
Confirm Flask is running with
host="0.0.0.0"inside Docker (not127.0.0.1). -
Port already in use:
Try using a different host port, for example:
docker run -p 9090:5000 flask-hello
Next Post Ideas
- Docker image layers and caching (explained simply)
- Docker volumes: keeping data after a container stops
- Running the same container in Kubernetes (Pod basics)