From 064c7135bc26488fd9e76410c06aaa16fd215497 Mon Sep 17 00:00:00 2001 From: Erik Nordin <58569820+nordzilla@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:57:10 -0600 Subject: [PATCH] Add --run-as-user flag to docker-run.py (#919) --- utils/tasks/docker-run.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/tasks/docker-run.py b/utils/tasks/docker-run.py index ca895ec6..36b29ee1 100755 --- a/utils/tasks/docker-run.py +++ b/utils/tasks/docker-run.py @@ -16,6 +16,12 @@ def get_args(): metavar="VOLUME", ) + parser.add_argument( + "--run-as-user", + action="store_true", + help="Run the Docker container as the current user's UID and GID.", + ) + args, other_args = parser.parse_known_args() args.other_args = other_args @@ -42,6 +48,12 @@ def main(): for volume in args.volume: docker_command.extend(["--volume", volume]) + # Run Docker with the current user's UID and GID if --run-as-user is specified + if args.run_as_user: + uid = os.getuid() + gid = os.getgid() + docker_command.extend(["--user", f"{uid}:{gid}"]) + # Specify the Docker image docker_command.append("translations-local")