Unable to run flask app in debug mode using Docker Unable to run flask app in debug mode using Docker flask flask

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.

screenshot can be viewed here

Summary of Steps in screenshot (MAC OS X):

  1. starting with Empty directory
  2. Create app.py
  3. docker run
  4. curl localhost (this will display Hello, World)
  5. edit app.py
  6. 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()