Skip to content

Commit

Permalink
Merge pull request #5611 from cloudtogo/rootfs-propagation
Browse files Browse the repository at this point in the history
ctr flags of container rootfs propagation
  • Loading branch information
fuweid committed Jun 17, 2021
2 parents 1dada3f + 05e5153 commit 11304a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/ctr/commands/commands_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ func init() {
}, cli.Uint64Flag{
Name: "cpu-period",
Usage: "Limit CPU CFS period",
}, cli.StringFlag{
Name: "rootfs-propagation",
Usage: "set the propagation of the container rootfs",
})
}
16 changes: 16 additions & 0 deletions cmd/ctr/commands/run/run_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/containerd/containerd"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/contrib/apparmor"
"github.com/containerd/containerd/contrib/nvidia"
"github.com/containerd/containerd/contrib/seccomp"
Expand Down Expand Up @@ -266,6 +267,21 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
for _, dev := range context.StringSlice("device") {
opts = append(opts, oci.WithDevices(dev, "", "rwm"))
}

rootfsPropagation := context.String("rootfs-propagation")
if rootfsPropagation != "" {
opts = append(opts, func(_ gocontext.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
if s.Linux != nil {
s.Linux.RootfsPropagation = rootfsPropagation
} else {
s.Linux = &specs.Linux{
RootfsPropagation: rootfsPropagation,
}
}

return nil
})
}
}

runtimeOpts, err := getRuntimeOptions(context)
Expand Down

0 comments on commit 11304a4

Please sign in to comment.