-
Notifications
You must be signed in to change notification settings - Fork 2.1k
docker run: specify cgroup namespace mode with --cgroupns #2024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ type containerOptions struct { | |
| pidMode string | ||
| utsMode string | ||
| usernsMode string | ||
| cgroupnsMode string | ||
| publishAll bool | ||
| stdin bool | ||
| tty bool | ||
|
|
@@ -198,6 +199,12 @@ func addFlags(flags *pflag.FlagSet) *containerOptions { | |
| flags.BoolVar(&copts.privileged, "privileged", false, "Give extended privileges to this container") | ||
| flags.Var(&copts.securityOpt, "security-opt", "Security Options") | ||
| flags.StringVar(&copts.usernsMode, "userns", "", "User namespace to use") | ||
| flags.StringVar(&copts.cgroupnsMode, "cgroupns", "", `Cgroup namespace to use (host|private) | ||
| 'host': Run the container in the Docker host's cgroup namespace | ||
| 'private': Run the container in its own private cgroup namespace | ||
| '': Use the cgroup namespace as configured by the | ||
| default-cgroupns-mode option on the daemon (default)`) | ||
| flags.SetAnnotation("cgroupns", "version", []string{"1.41"}) | ||
|
|
||
| // Network and port publishing flag | ||
| flags.Var(&copts.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)") | ||
|
|
@@ -469,6 +476,11 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con | |
| return nil, errors.Errorf("--userns: invalid USER mode") | ||
| } | ||
|
|
||
| cgroupnsMode := container.CgroupnsMode(copts.cgroupnsMode) | ||
| if !cgroupnsMode.Valid() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this; I'm a bit on the fence if we should validate this on the client side, or just leave it to the daemon to return an error if an invalid value was provided. OTOH, these values likely won't change in future, so perhaps it's ok @kolyshkin wdyt?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's ok for now, given that it likely won't change in future, but I'll open a follow-up issue after this is merged to discuss this |
||
| return nil, errors.Errorf("--cgroupns: invalid CGROUP mode") | ||
| } | ||
|
|
||
| restartPolicy, err := opts.ParseRestartPolicy(copts.restartPolicy) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -620,6 +632,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con | |
| PidMode: pidMode, | ||
| UTSMode: utsMode, | ||
| UsernsMode: usernsMode, | ||
| CgroupnsMode: cgroupnsMode, | ||
| CapAdd: strslice.StrSlice(copts.capAdd.GetAll()), | ||
| CapDrop: strslice.StrSlice(copts.capDrop.GetAll()), | ||
| GroupAdd: copts.groupAdd.GetAll(), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.