{"record":{"id":"6466fdd22e825c07","repo":"docker/cli","slug":"pid-invalid-pid-mode","errorCode":null,"errorMessage":"--pid: invalid PID mode","messagePattern":"--pid: invalid PID mode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":520,"sourceCode":"\t\t}\n\t\tdeviceMappings = append(deviceMappings, deviceMapping)\n\t}\n\n\t// collect all the environment variables for the container\n\tenvVariables, err := opts.ReadKVEnvStrings(copts.envFile.GetSlice(), copts.env.GetSlice())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"--env-file: %w\", err)\n\t}\n\n\t// collect all the labels for the container\n\tlabels, err := opts.ReadKVStrings(copts.labelsFile.GetSlice(), copts.labels.GetSlice())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"--label-file: %w\", err)\n\t}\n\n\tpidMode := container.PidMode(copts.pidMode)\n\tif !pidMode.Valid() {\n\t\treturn nil, errors.New(\"--pid: invalid PID mode\")\n\t}\n\n\tutsMode := container.UTSMode(copts.utsMode)\n\tif !utsMode.Valid() {\n\t\treturn nil, errors.New(\"--uts: invalid UTS mode\")\n\t}\n\n\tusernsMode := container.UsernsMode(copts.usernsMode)\n\tif !usernsMode.Valid() {\n\t\treturn nil, errors.New(\"--userns: invalid USER mode\")\n\t}\n\n\tcgroupnsMode := container.CgroupnsMode(copts.cgroupnsMode)\n\tif !cgroupnsMode.Valid() {\n\t\treturn nil, errors.New(\"--cgroupns: invalid CGROUP mode\")\n\t}\n\n\trestartPolicy, err := opts.ParseRestartPolicy(copts.restartPolicy)","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L502-L538","documentation":"Returned when the value passed to --pid fails container.PidMode.Valid() (opts.go:518-521). Valid PID modes are the empty string (default/private), \"host\", or \"container:<name-or-id>\". Any malformed value (e.g. a typo, missing container: prefix, or unsupported keyword) is rejected before container creation.","triggerScenarios":"Running `docker run --pid=<bad> ...` where <bad> is not one of: empty, \"host\", or \"container:<id>\". For example `--pid=container:` (empty id), `--pid=shared`, `--pid=hosk`.","commonSituations":"Typing the namespace keyword incorrectly; forgetting the `container:` prefix when sharing a PID namespace; assuming `--pid=shared` or other cgroup-style keywords are supported.","solutions":["Use `--pid=host` to share the host PID namespace.","Use `--pid=container:<name|id>` to share another container's PID namespace.","Omit the flag to use the default private PID namespace.","Double-check for typos in the keyword."],"exampleFix":"// before\ndocker run --pid=container: myimage\n// after\ndocker run --pid=container:webapp myimage","handlingStrategy":"validation","validationCode":"// Validate the PID mode before invoking the client.\nif pm := container.PidMode(copts.pidMode); !pm.Valid() {\n    return fmt.Errorf(\"--pid: invalid PID mode %q\", copts.pidMode)\n}","typeGuard":"// isValidPidMode narrows acceptable --pid values.\nfunc isValidPidMode(s string) bool {\n    return s == \"\" || s == \"host\" || strings.HasPrefix(s, \"container:\")\n}","tryCatchPattern":null,"preventionTips":["Whitelist empty, host, and container:<id> in form/arg validators.","Reject container: with an empty suffix early.","Add shell completion hints limited to valid values."],"tags":["docker-cli","pid-namespace","validation","namespace","container-create"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}