Issue
Using this for DockerFile, on running with
docker run -p 5000:5000 flask_app:1.0
It runs but browser is showing 127.0.0.1 refused to connect.
RUN apt-get update \
&& apt-get install tesseract-ocr -y \
python3 \
#python-setuptools \
python3-pip \
&& apt-get clean \
&& apt-get autoremove
ADD . /home/App
WORKDIR /home/App
COPY requirements.txt ./
COPY . .
RUN pip3 install -r requirements.txt
VOLUME ["/data"]
EXPOSE 5000
ENTRYPOINT [ "python3" ]
CMD [ "app.py" ]```
Solution
You are probably listening on interface 127.0.0.1. You need to listen on 0.0.0.0, e.g. app.run(host="0.0.0.0", port=5000)
.
Basically the container and your host have different 127.0.0.1, so you need to bind to external IPs. For more details, and diagrams, see https://pythonspeed.com/articles/docker-connection-refused/
Answered By - Itamar Turner-Trauring
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.