From dd0539b0955a7686dadfb70f6fe5fbc216386d82 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 6 Nov 2018 16:03:40 +0900 Subject: [PATCH] ctr: add --cgroup for oci.WithCgroup Signed-off-by: Akihiro Suda --- cmd/ctr/commands/run/run.go | 4 ++++ cmd/ctr/commands/run/run_unix.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/ctr/commands/run/run.go b/cmd/ctr/commands/run/run.go index 314d89177..5c4861e03 100644 --- a/cmd/ctr/commands/run/run.go +++ b/cmd/ctr/commands/run/run.go @@ -110,6 +110,10 @@ var Command = cli.Command{ Name: "isolated", Usage: "run the container with vm isolation", }, + cli.StringFlag{ + Name: "cgroup", + Usage: "cgroup path (To disable use of cgroup, set to \"\" explicitly)", + }, }, append(commands.SnapshotterFlags, commands.ContainerFlags...)...), Action: func(context *cli.Context) error { var ( diff --git a/cmd/ctr/commands/run/run_unix.go b/cmd/ctr/commands/run/run_unix.go index 1291bfd20..11c5f2f50 100644 --- a/cmd/ctr/commands/run/run_unix.go +++ b/cmd/ctr/commands/run/run_unix.go @@ -141,6 +141,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli if context.IsSet("allow-new-privs") { opts = append(opts, oci.WithNewPrivileges) } + if context.IsSet("cgroup") { + // NOTE: can be set to "" explicitly for disabling cgroup. + opts = append(opts, oci.WithCgroup(context.String("cgroup"))) + } } cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))