Skip to content

Commit

Permalink
docker.py: add --run-as-current-user
Browse files Browse the repository at this point in the history
(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>
  • Loading branch information
elmarco committed Aug 22, 2019
1 parent 8109234 commit 2461d80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/docker/Makefile.include
Expand Up @@ -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,) \
Expand Down
5 changes: 5 additions & 0 deletions tests/docker/docker.py
Expand Up @@ -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)


Expand Down

0 comments on commit 2461d80

Please sign in to comment.