0

I have a flask app, if use "python app.py" to start the server, it runs perfectly. The browser client can get what I want.

However, if I use docker container, If I use below DockerFile:

FROM python:3.6.5-slim
RUN mkdir /opt/convosimUI
WORKDIR /opt/convosimUI

RUN pip install Flask
RUN pip install grpcio
RUN pip install grpcio-tools
ADD . .

EXPOSE 5000

ENV FLASK_APP=app.py

CMD ["python", "-u", "app.py"]

The browser (on windows) can not get response from server, in the linux container, everything works perfect and I can use wget to get content of 127.0.0.1, but outside the container, everything in container is not accessible.

If I change the lask line of DockerFile into:

CMD ["flask", "run", "--host", "0.0.0.0"]

Not use python app.py, then it works again.

Why this happen? And how if I want to use python app.py command?

It because there're some other parallel processing in app.py which I need to share the client of another service, and this client must be always on when turn on the web server. So I can not just put them in separate place.

Any ideas are welcome. Thanks!

Jie Hu
  • 539
  • 1
  • 5
  • 16
  • Please have a look at this question here, it's the same and the answers have the info you need: https://stackoverflow.com/questions/7023052/configure-flask-dev-server-to-be-visible-across-the-network. – takacsmark Jun 11 '18 at 06:08
  • yes, I've modified to 0.0.0.0, tnx. – Jie Hu Jun 13 '18 at 23:34

0 Answers0