From 0c79257f594737e00acbe1b26338c9d8d22697f4 Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Tue, 1 Mar 2022 15:28:51 -0800 Subject: [PATCH] Add --user support for ctr run Windows Adds the ability to override the default user ContainerUser with a custom user if present in the image or ContainerAdministrator if needed. Signed-off-by: Justin Terry --- cmd/ctr/commands/run/run_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/ctr/commands/run/run_windows.go b/cmd/ctr/commands/run/run_windows.go index a2d85d75e..5e5006430 100644 --- a/cmd/ctr/commands/run/run_windows.go +++ b/cmd/ctr/commands/run/run_windows.go @@ -36,6 +36,10 @@ var platformRunFlags = []cli.Flag{ Name: "isolated", Usage: "run the container with vm isolation", }, + cli.StringFlag{ + Name: "user", + Usage: "run the container as the specified user", + }, } // NewContainer creates a new container @@ -104,6 +108,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli if cwd := context.String("cwd"); cwd != "" { opts = append(opts, oci.WithProcessCwd(cwd)) } + if user := context.String("user"); user != "" { + opts = append(opts, oci.WithUsername(user)) + } if context.Bool("tty") { opts = append(opts, oci.WithTTY)