码头工人无法启动烧瓶应用程序

时间:2020-02-18 03:47:46

标签: docker flask

flask应用程序已启动,但是我无法从浏览器查看任何内容。

root@1ec89cb3dad1:/app# python main.py
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 231-587-342

Dockerfile看起来像这样:

FROM ubuntu
RUN apt-get update -y && \
    apt-get install -y python-pip python-dev  libhunspell-dev
WORKDIR /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
ENTRYPOINT [ "python" ]
CMD [ "main.py" ]

文件在这里... https://github.com/shantanuo/Spell-Checker/tree/master

我不确定是否应该标记docker或flask!


更新:

我使用这些命令来构建和运行图像...

git clone https://github.com/shantanuo/Spell-Checker.git

cd Spell-Checker/

docker build -t shantanuo/flask .

docker run -p 5000:5000 shantanuo/flask

1 个答案:

答案 0 :(得分:1)

您的应用仅监听本地主机(127.0.0.1),但是您需要允许远程访问(通常为0.0.0.0

您的代码应设置app.run(host="0.0.0.0")

请参阅: