Unable to run flask app in debug mode using Docker
A sample (simplifed) runthru demostrating file edits with no need for container restarts outlined below for your reference.
app.py
from flask import Flaskapp = Flask(__name__)@app.route('/')def hello_world(): return "Hello, World"if __name__ == '__main__': app.run(debug=True,host='0.0.0.0',port=80)
You will need to specify the port for the flask development server in order to match the exposed container port of 80.
Summary of Steps in screenshot (MAC OS X):
- starting with Empty directory
- Create app.py
- docker run
- curl localhost (this will display Hello, World)
- edit app.py
- curl localhost (this should display the new edits)
in my case I had a conflict with gevent. here's the workaround:
import osif not (os.environ.get('FLASK_DEBUG') == 1): from gevent import monkey monkey.patch_all()