Dockerfile using source image https://hub.docker.com/_/python
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
EXPOSE 5000
CMD [ "python", "./app.py" ]
Source code of app.py
from flask import Flask
app = Flask(__name__)
@app.route("/<name>")
def hello(name):
return "Hello {}, Welcome to Python Web App with Flask".format(name)
if __name__ == "__main__":
app.run(host="0.0.0.0",debug=True)
Add requirements.txt as below
Flask
You can then build and run the Docker image: you can use any port which is available on your host instead of 8080
$ docker pull anguda/python-flask-app:latest
$ docker run -d -p 8080:5000 --name my-running-app anguda/python-flask-app
Access Application as like
localhost:8080/anguda
Content type
Image
Digest
Size
336.7 MB
Last updated
over 6 years ago
docker pull anguda/python-flask-app