default join cgroup namespace in runc example

Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
lifubang 2020-04-17 15:57:42 +08:00
parent e4981c91b5
commit d0f9b9ce42
1 changed files with 8 additions and 1 deletions

View File

@ -4,13 +4,14 @@ import (
"os"
"strings"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runtime-spec/specs-go"
)
// Example returns an example spec file, with many options set so a user can
// see what a standard spec file looks like.
func Example() *specs.Spec {
return &specs.Spec{
spec := &specs.Spec{
Version: specs.Version,
Root: &specs.Root{
Path: "rootfs",
@ -155,6 +156,12 @@ func Example() *specs.Spec {
},
},
}
if cgroups.IsCgroup2UnifiedMode() {
spec.Linux.Namespaces = append(spec.Linux.Namespaces, specs.LinuxNamespace{
Type: "cgroup",
})
}
return spec
}
// ToRootless converts the given spec file into one that should work with