This repository contains a simple Flask "Hello World" application that can be containerized using Docker. The Flask application is configured to read an environment variable to greet users.
- Python 3.9+
- Docker
The Flask application (app.py
) serves a greeting message. By default, it will greet "World", but you can customize the greeting message using the GREETING
environment variable.
A Dockerfile
is provided to containerize the application.
To build the Docker image, navigate to the directory containing the Dockerfile
and run:
docker build -t flask-hello-world .
This command builds the Docker image and tags it as flask-hello-world
.
To run the container and serve the Flask application:
docker run -p 5000:5000 -e GREETING='Docker World' flask-hello-world
The application will be accessible at http://localhost:5000
.
To push the image to Docker Hub, follow these steps:
-
Login to Docker Hub:
docker login
-
Tag Your Image:
Replace
myusername
with your Docker Hub username:docker tag flask-hello-world myusername/my-flask-app:latest
-
Push the Image:
docker push myusername/my-flask-app:latest
-
Your image will now be available publicly on Docker Hub.
This repository offers a quick way to containerize a simple Flask application and push it to Docker Hub. Always remember to avoid including any sensitive data in your Docker images and always follow best practices for Docker and Flask applications.