Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions completions/bash/ocitools
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,20 @@ _ocitools_generate() {
--bind
--cap-add
--cap-drop
--cgroup
--cwd
--env
--gid
--gidmappings
--groups
--hostname
--help
--ipc
--mount
--mount-cgroups
--network
--os
--pid
--poststart
--poststop
--prestart
Expand All @@ -297,17 +302,14 @@ _ocitools_generate() {
--tmpfs
--uid
--uidmappings
--uts
"

local boolean_options="
--ipc
--network
--no-new-privileges
--mount
--pid
--privileged
--read-only
--uts
--tty
"

local all_options="$options_with_args $boolean_options"
Expand Down
5 changes: 4 additions & 1 deletion generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var generateFlags = []cli.Flag{
cli.StringSliceFlag{Name: "groups", Usage: "supplementary groups for the process"},
cli.StringSliceFlag{Name: "cap-add", Usage: "add capabilities"},
cli.StringSliceFlag{Name: "cap-drop", Usage: "drop capabilities"},
cli.StringFlag{Name: "cgroup", Usage: "cgroup namespace"},
cli.StringFlag{Name: "network", Usage: "network namespace"},
cli.StringFlag{Name: "mount", Usage: "mount namespace"},
cli.StringFlag{Name: "pid", Usage: "pid namespace"},
Expand Down Expand Up @@ -672,6 +673,8 @@ func mapStrToNamespace(ns string, path string) rspec.Namespace {
return rspec.Namespace{Type: rspec.UTSNamespace, Path: path}
case "user":
return rspec.Namespace{Type: rspec.UserNamespace, Path: path}
case "cgroup":
return rspec.Namespace{Type: rspec.CgroupNamespace, Path: path}
default:
logrus.Fatalf("Should not reach here!")
}
Expand All @@ -684,7 +687,7 @@ func setupNamespaces(spec *rspec.Spec, context *cli.Context) {
needsNewUser = true
}

namespaces := []string{"network", "pid", "mount", "ipc", "uts", "user"}
namespaces := []string{"network", "pid", "mount", "ipc", "uts", "user", "cgroup"}
for _, nsName := range namespaces {
if !context.IsSet(nsName) && !(needsNewUser && nsName == "user") {
continue
Expand Down
5 changes: 5 additions & 0 deletions man/ocitools-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ compatible runtime like runC to run a container.
**--cap-drop**=[]
Drop Linux capabilities

**--cgroup**=[*PATH*]
Use a Cgroup namespace. If *PATH* is set, join that namespace. If it
is unset, create a new namespace. The special *PATH* `host` removes
any existing Cgroup namespace from the configuration.

**--cgroups-path**=""
Specifiy the path to the cgroups relative to the cgroups mount point.

Expand Down