Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,6 +27,10 @@ Options: | ||
| --blkio-weight-device value Block IO weight (relative device weight) (default []) | ||
| --cap-add value Add Linux capabilities (default []) | ||
| --cap-drop value Drop Linux capabilities (default []) | ||
| --cgroupns string Cgroup namespace to use | ||
thaJeztah marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 'host': Run the container in the Docker host's cgroup namespace | ||
| 'private': Run the container in its own private cgroup namespace | ||
| '': Use the default Docker daemon cgroup namespace specified by the `--default-cgroupns-mode` option | ||
| --cgroup-parent string Optional parent cgroup for the container | ||
| --cidfile string Write the container ID to the file | ||
| --cpu-count int The number of CPUs available for execution by the container. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,6 +13,7 @@ docker-run - Run a command in a new container | ||
| [**--cpu-shares**[=*0*]] | ||
| [**--cap-add**[=*[]*]] | ||
| [**--cap-drop**[=*[]*]] | ||
| [**--cgroupns**[=*[]*]] | ||
| [**--cgroup-parent**[=*CGROUP-PATH*]] | ||
| [**--cidfile**[=*CIDFILE*]] | ||
| [**--cpu-count**[=*0*]] | ||
| @@ -173,6 +174,12 @@ division of CPU shares: | ||
| **--cap-drop**=[] | ||
| Drop Linux capabilities | ||
| **--cgroupns**="" | ||
| Set the cgroup namespace mode for the container. | ||
| **host**: run the container in the host's cgroup namespace | ||
| **private**: run the container in its own private cgroup namespace | ||
| **""**: (unset) run the container in the host's cgroup namespace | ||
thaJeztah marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| **--cgroup-parent**="" | ||
| Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist. | ||
Uh oh!
There was an error while loading. Please reload this page.