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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ Basic flags:
- :whale: `--rm`: Automatically remove the container when it exits
- :whale: `--pull=(always|missing|never)`: Pull image before running
- Default: "missing"
- :whale: `--pid=(host)`: PID namespace to use

Network flags:
- :whale: `--net, --network=(bridge|host|none|<CNI>)`: Connect a container to a network
Expand Down
14 changes: 14 additions & 0 deletions cmd/nerdctl/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ var runCommand = &cli.Command{
Aliases: []string{"m"},
Usage: "Memory limit",
},
// Enable host pid namespace
&cli.StringFlag{
Name: "pid",
Usage: "PID namespace to use",
},
&cli.IntFlag{
Name: "pids-limit",
Usage: "Tune container pids limit (set -1 for unlimited)",
Expand Down Expand Up @@ -484,6 +489,15 @@ func runAction(clicontext *cli.Context) error {
opts = append(opts, oci.WithDevShmSize(shmBytes/1024))
}

pidNs := strings.ToLower(clicontext.String("pid"))
if pidNs != "" {
if pidNs != "host" {
return fmt.Errorf("Invalid pid namespace. Set --pid=host to enable host pid namespace.")
} else {
opts = append(opts, oci.WithHostNamespace(specs.PIDNamespace))
}
}

rtCOpts, err := generateRuntimeCOpts(clicontext)
if err != nil {
return err
Expand Down