Reputation: 61
I have a problem running a little Flask app with Docker. Everything works fine with debug off, but when I try to run it with debug on it fails at the reloader stage. It works fine on Windows, the problem only comes up with Docker.
In my docker repo I install caffe and all the dependencies I need (flask and wekrzeug). I thought the problem could be with the reloader so I also installed watchdog but it still shows up. Doesn't matter whether I run app.py itself or call python -m flask run.
docker run --volume=%cd%:/workspace -p 5001:5000 caffe:cpu
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with inotify reloader
Traceback (most recent call last):
File "app.py", line 53, in <module>
app.run(debug = True, host='0.0.0.0')
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 943, in run
run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 988, in run_simple
run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
sys.exit(reloader.restart_with_reloader())
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
exit_code = subprocess.call(args, env=new_environ, close_fds=False)
File "/usr/lib/python2.7/subprocess.py", line 523, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Upvotes: 3
Views: 1428
Reputation: 995
Try to run the app as a module:
python -m flask run
See https://github.com/pallets/flask/issues/1829 for more information.
Upvotes: 0
Reputation: 530
I've encountered the same problem here and the solution for me was to remove the executable flag from the "run.py" file.
$ chmod -x run.py
The error was very similar, but in my case I'm using an Ubuntu 18.04 WSL on a Windows 10 machine.
Upvotes: 2