I've built a Docker image containing a simple Flask test app:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "Hello World!"
if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0')
using the Dockerfile
:
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install -r /app/requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
The Docker image was built using docker build -t flask-app .
and it has been successfully created:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
flask-app latest fab0d79fd7ac 8 minutes ago 642.2 MB
ubuntu latest 104bec311bcd 5 weeks ago 129 MB
and I've run it using:
$ docker run -d -p 5000:5000 flask-app
e92b249dd02ca44489069b783fa9be713c7a14ea893061194e37c80f16d8c931
I'm assuming that I can test the app by pointing the browser to http://localhost:5000/
but I get a timeout. What could be going wrong?