I make a docker image for datetime flask api in python. I cannot see the output on the specified port when I visit browser on http://127.0.0.1:5000/
flask api python code app.py
from flask import Flask,jsonify
from datetime import datetime
app = Flask(__name__)
@app.route("/")
def hello():
now = datetime.now()
return jsonify( {"Date and Time: ": now})
if __name__ == '__main__':
app.run(debug=True)
Dockerfile
FROM python:3.7.4
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
requirements.txt
flask==1.1.2
The three files [ 'app.py', 'Dockerfile', 'requirements.txt'] are in 'my_docker_flask' folder. I run the following commands inside the folder
I build and run the docker
docker build -t my_docker_flask:latest .
docker run -p 5000:5000 my_docker_flask:latest
I cannot see the output on the specified port when I visit browser on http://127.0.0.1:5000/ What am I doing wrong?