Skip to content

Commit

Permalink
command line flags of setting container rootfs propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
kitt1987 committed Jun 16, 2021
1 parent 0a3a77b commit 621d697
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 @@ -21,6 +21,7 @@ package run
import (
gocontext "context"
"fmt"
"github.com/containerd/containerd/containers"
"path/filepath"
"strconv"
"strings"
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 621d697

Please sign in to comment.