Debug mode.
dmitryr117 opened this issue · comments
Is there a debug mode available for this image? Tried to set environment variable in docker-compose.yml to FLASK_DEBUG: 1, and tried to use
if name == 'main':
app.run(debug=True,host='0.0.0.0',port=80)
in python file. But everything does not seem to work. Only restarting the container works.
You can run an interactive bash session, like:
docker run -it -p 80:80 -e MODULE_NAME="custom_app.custom_main" myimage bash
And inside of it run your Flask application with the Flask command:
FLASK_ENV=development FLASK_APP=hello.py flask run
Have in mind that this is only for debug/development. And it completely overrides Meinheld and Gunicorn. They won't in this case, only your Flask development server. But you can use it during development and then remove it for production.
For others that are looking to run in debug mode from docker-compose, this is working for me. I use this in the docker-compose.override.yml file for development. As @tiangolo mentioned, this completely overrides Meinheld and Gunicorn.
version: '3.5'
services:
thisapp:
ports:
- "80:5000"
stdin_open: true
tty: true
environment:
- FLASK_APP=app
- FLASK_ENV=development
command: /bin/bash -c "flask run --host=0.0.0.0"
FLASK_APP, in my case, is the name of the subfolder under the main "app" folder. My setup is /app/app/__init__.py
. There may be a better way, but this works for me.
Yep, great @jaskipper ! Thanks for sharing it.
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.