Reputation: 281
Dockerfile
from ubuntu:latest
RUN apt-get update -y && apt-get install -y python3-pip
COPY . /app
RUN pip3 install -r /app/requirements.txt
ENTRYPOINT ["python3"]
CMD ["app/app.py"]
run commands
docker build -t flaskapp .
docker run -it -d p 5000:5000 flaskapp
if i sent a request to localhost:5000
via Postman, i would get a Error: Socket hang up
error
Anyone know why this is an issue?
Upvotes: 8
Views: 10947
Reputation: 69
I had a similar issue and resolved it like via these two methods. Try making either of these changes in your code:
1. Add hostname - Add any IP host (127.0.0.1 or whatever you like) in your flask code itself like this:
if __name__ == "__main__":
app.run(host='0.0.0.0',debug=True,port='9999')
2. Add WORKDIR
in your Dockerfile - Not mandatory but a try.
Upvotes: 6
Reputation: 281
the exposed host in my flask app was 127.0.0.1
in which i had to switch to 0.0.0.0
Upvotes: 12