我怎样才能打开我的浏览器上的Docker远程运行瓶应用程序?

我正在运行使用Pycharm烧瓶应用程序,我得到以下消息:信息:werkzeug:*运行在http://0.0.0.0:5000/ (按Ctrl + C退出)

我一直在试图从我的本地浏览器访问该网站,它不工作。 首先,我在Pycharm中尝试了以下内容,但无法运行:“运行>编辑configuration> Docker部署>容器>添加端口绑定>容器端口= 5000>主机端口= 5000”。 这是正确的吗? 我应该添加一些东西在主机IP?

我也尝试访问构build,执行> docker中的API URL,但它不工作。

解决这个问题的更简单的方法是什么?

app.py

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') 

你可以直接提供主机IP

requirements.txt

 Flask==0.10.1 

或者它可以是任何版本

Dockerfile

 FROM ubuntu:16.04 MAINTANER Your Name "youremail@domain.tld" RUN apt-get update -y && \ apt-get install -y python-pip python-dev #your Dockerfile is missing this line COPY ./requirements.txt /app/requirements.txt WORKDIR /app RUN pip install -r requirements.txt COPY . /app ENTRYPOINT [ "python" ] CMD [ "app.py" ] 

docker命令来运行

 docker build -t flaskapp:latest . #flask runs in default port 5000 docker run -d -p 5000:5000 flaskapp 

在浏览器中: http:// localhost:5000