Skip to content

Commit dd0539b

Browse files
committed
ctr: add --cgroup for oci.WithCgroup
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
1 parent 8dcabd6 commit dd0539b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cmd/ctr/commands/run/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ var Command = cli.Command{
110110
Name: "isolated",
111111
Usage: "run the container with vm isolation",
112112
},
113+
cli.StringFlag{
114+
Name: "cgroup",
115+
Usage: "cgroup path (To disable use of cgroup, set to \"\" explicitly)",
116+
},
113117
}, append(commands.SnapshotterFlags, commands.ContainerFlags...)...),
114118
Action: func(context *cli.Context) error {
115119
var (

cmd/ctr/commands/run/run_unix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
141141
if context.IsSet("allow-new-privs") {
142142
opts = append(opts, oci.WithNewPrivileges)
143143
}
144+
if context.IsSet("cgroup") {
145+
// NOTE: can be set to "" explicitly for disabling cgroup.
146+
opts = append(opts, oci.WithCgroup(context.String("cgroup")))
147+
}
144148
}
145149

146150
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), nil))

0 commit comments

Comments
 (0)