When launching an application with the Werkzeug debugger in Docker with a custom UID, the debugger fails while trying to construct a PIN.
Traceback (most recent call last):
File "/usr/local/bin/flask", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 894, in main
cli.main(args=args, prog_name=name)
File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 557, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/flask/cli.py", line 771, in run_command
threaded=with_threads, ssl_context=cert)
File "/usr/local/lib/python3.7/site-packages/werkzeug/serving.py", line 751, in run_simple
application = DebuggedApplication(application, use_evalex)
File "/usr/local/lib/python3.7/site-packages/werkzeug/debug/__init__.py", line 258, in __init__
if self.pin is None:
File "/usr/local/lib/python3.7/site-packages/werkzeug/debug/__init__.py", line 268, in _get_pin
self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app)
File "/usr/local/lib/python3.7/site-packages/werkzeug/debug/__init__.py", line 148, in get_pin_and_cookie_name
username = getpass.getuser()
File "/usr/local/lib/python3.7/getpass.py", line 169, in getuser
return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 1001'
Maybe a workaround could be create the user group and the user inside the docker instance, but it's not scalable.
When launching an application with the Werkzeug debugger in Docker with a custom UID, the debugger fails while trying to construct a PIN.
werkzeug/werkzeug/debug/__init__.py
Line 148 in 6fc07fe
It seems that Werkzeug fails on this line when trying to get the user with
$UIDspecified indocker-compose.yml.Maybe a workaround could be create the user group and the user inside the docker instance, but it's not scalable.
docker-compose.yml:Dockerfile: