docker.py: add --run-as-current-user
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Fri, 12 Jul 2019 10:50:52 +0000 (14:50 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 22 Aug 2019 13:30:25 +0000 (17:30 +0400)
(podman will need further tweaks)

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/docker/Makefile.include
tests/docker/docker.py

index dbd58e548c102e2eb074b86fb78ee12cf7234d64..582846a58797b5f6d27d585b51c5c9db1c61ef2d 100644 (file)
@@ -212,7 +212,7 @@ docker-run: docker-qemu-src
                        "  COPYING $(EXECUTABLE) to $(IMAGE)"))
        $(call quiet-command,                                           \
                $(DOCKER_SCRIPT) run                                    \
-                       $(if $(NOUSER),,-u $(shell id -u))              \
+                       $(if $(NOUSER),,--run-as-current-user)          \
                        --security-opt seccomp=unconfined               \
                        $(if $V,,--rm)                                  \
                        $(if $(DEBUG),-ti,)                             \
index 53a8c9c801e96d37118a727319d3afb603769839..f15545aeea3f1b2884db644fd4721a53b54ce396 100755 (executable)
@@ -333,8 +333,13 @@ class RunCommand(SubCommand):
     def args(self, parser):
         parser.add_argument("--keep", action="store_true",
                             help="Don't remove image when command completes")
+        parser.add_argument("--run-as-current-user", action="store_true",
+                            help="Run container using the current user's uid")
 
     def run(self, args, argv):
+        if args.run_as_current_user:
+            uid = os.getuid()
+            argv = [ "-u", str(uid) ] + argv
         return Docker().run(argv, args.keep, quiet=args.quiet)