ctr: add --cgroup for oci.WithCgroup

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2018-11-06 16:03:40 +09:00
parent 8dcabd6125
commit dd0539b095
2 changed files with 8 additions and 0 deletions

View File

@ -110,6 +110,10 @@ var Command = cli.Command{
Name: "isolated", Name: "isolated",
Usage: "run the container with vm isolation", 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...)...), }, append(commands.SnapshotterFlags, commands.ContainerFlags...)...),
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
var ( var (

View File

@ -141,6 +141,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if context.IsSet("allow-new-privs") { if context.IsSet("allow-new-privs") {
opts = append(opts, oci.WithNewPrivileges) 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)) cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))