Skip to content

Commit 11304a4

Browse files
authored
Merge pull request #5611 from cloudtogo/rootfs-propagation
ctr flags of container rootfs propagation
2 parents 1dada3f + 05e5153 commit 11304a4

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

cmd/ctr/commands/commands_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ func init() {
3636
}, cli.Uint64Flag{
3737
Name: "cpu-period",
3838
Usage: "Limit CPU CFS period",
39+
}, cli.StringFlag{
40+
Name: "rootfs-propagation",
41+
Usage: "set the propagation of the container rootfs",
3942
})
4043
}

cmd/ctr/commands/run/run_unix.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/containerd/containerd"
2929
"github.com/containerd/containerd/cmd/ctr/commands"
30+
"github.com/containerd/containerd/containers"
3031
"github.com/containerd/containerd/contrib/apparmor"
3132
"github.com/containerd/containerd/contrib/nvidia"
3233
"github.com/containerd/containerd/contrib/seccomp"
@@ -266,6 +267,21 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
266267
for _, dev := range context.StringSlice("device") {
267268
opts = append(opts, oci.WithDevices(dev, "", "rwm"))
268269
}
270+
271+
rootfsPropagation := context.String("rootfs-propagation")
272+
if rootfsPropagation != "" {
273+
opts = append(opts, func(_ gocontext.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
274+
if s.Linux != nil {
275+
s.Linux.RootfsPropagation = rootfsPropagation
276+
} else {
277+
s.Linux = &specs.Linux{
278+
RootfsPropagation: rootfsPropagation,
279+
}
280+
}
281+
282+
return nil
283+
})
284+
}
269285
}
270286

271287
runtimeOpts, err := getRuntimeOptions(context)

0 commit comments

Comments
 (0)