【发布时间】:2021-09-12 16:09:02
【问题描述】:
我在 docker 中有这个烧瓶应用程序,调试模式设置为开启:
app_1 | * Serving Flask app 'my_app' (lazy loading)
app_1 | * Environment: development
app_1 | * Debug mode: on
app_1 | * Running on all addresses.
app_1 | WARNING: This is a development server. Do not use it in a production deployment.
app_1 | * Running on http://172.22.0.2:5000/ (Press CTRL+C to quit)
app_1 | * Restarting with stat
app_1 | * Debugger is active!
app_1 | * Debugger PIN: 140-110-975
当我遇到错误并单击控制台小图标时,系统会询问我输入的 PIN 码,然后得到:[console ready]。
但是,当我在控制台中输入内容时,我有:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
到网址:http://localhost:5000/submit?&__debugger__=yes&cmd=dump()&frm=140300814179632&s=ljASKJ6S2EwWtVcN8EHR
我认为可能是正确的端口未打开,因为它可能是用于 websockets(webpack 中的热重载),但在这里,端口似乎与 web 应用程序相同(5000)。
那么知道什么地方会出错吗?
谢谢
我正在使用:
Python 3.9.5
Flask 2.0.1
编辑
这里是docker-compose.yml:
version: "3.3"
services:
app:
build: .
command: flask run --host=0.0.0.0 --debugger
volumes:
- .:/app
working_dir: /app
ports:
- 5000:5000
env_file:
- .env
【问题讨论】:
-
请添加 docker run 命令(或 docker compose)。你是用端口映射还是别的什么?
-
让flask监听所有IP地址:
app.run(host='0.0.0.0'). -
@ofirule 我用我的 docker-compose.yml 文件进行了编辑。 anemyte,这已经通过 CLI 完成了。