Skip to content

Commit

Permalink
Merge pull request #39299 from AkihiroSuda/ro-none-cgroupdriver
Browse files Browse the repository at this point in the history
info: report cgroup driver as "none" when running rootless
  • Loading branch information
thaJeztah committed Jun 3, 2019
2 parents 0105613 + ca5aab1 commit 3d21b86
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/swagger.yaml
Expand Up @@ -3818,7 +3818,7 @@ definitions:
description: |
The driver to use for managing cgroups.
type: "string"
enum: ["cgroupfs", "systemd"]
enum: ["cgroupfs", "systemd", "none"]
default: "cgroupfs"
example: "cgroupfs"
NEventsListener:
Expand Down Expand Up @@ -4053,7 +4053,7 @@ definitions:
SecurityOptions:
description: |
List of security features that are enabled on the daemon, such as
apparmor, seccomp, SELinux, and user-namespaces (userns).
apparmor, seccomp, SELinux, user-namespaces (userns), and rootless.
Additional configuration options for each security feature may
be present, and are included as a comma-separated list of key/value
Expand All @@ -4066,6 +4066,7 @@ definitions:
- "name=seccomp,profile=default"
- "name=selinux"
- "name=userns"
- "name=rootless"
ProductLicense:
description: |
Reports a summary of the product license on the daemon.
Expand Down
7 changes: 7 additions & 0 deletions daemon/daemon_unix.go
Expand Up @@ -73,6 +73,7 @@ const (
// constant for cgroup drivers
cgroupFsDriver = "cgroupfs"
cgroupSystemdDriver = "systemd"
cgroupNoneDriver = "none"

// DefaultRuntimeName is the default runtime to be used by
// containerd if none is specified
Expand Down Expand Up @@ -584,6 +585,9 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
}

func (daemon *Daemon) getCgroupDriver() string {
if daemon.Rootless() {
return cgroupNoneDriver
}
cgroupDriver := cgroupFsDriver

if UsingSystemd(daemon.configStore) {
Expand All @@ -610,6 +614,9 @@ func VerifyCgroupDriver(config *config.Config) error {
if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
return nil
}
if cd == cgroupNoneDriver {
return fmt.Errorf("native.cgroupdriver option %s is internally used and cannot be specified manually", cd)
}
return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
}

Expand Down
6 changes: 5 additions & 1 deletion docs/api/version-history.md
Expand Up @@ -22,7 +22,11 @@ keywords: "API, Docker, rcli, REST, documentation"
`private` to create the container in its own private cgroup namespace. The per-daemon
default is `host`, and can be changed by using the`CgroupNamespaceMode` daemon configuration
parameter.

* `GET /info` now includes `name=rootless` in `SecurityOptions` when the daemon is running in
rootless mode. This change is not versioned, and affects all API versions if the daemon has
this patch.
* `GET /info` now returns `none` as `CgroupDriver` when the daemon is running in rootless mode.
This change is not versioned, and affects all API versions if the daemon has this patch.

## v1.40 API changes

Expand Down
2 changes: 2 additions & 0 deletions docs/rootless.md
Expand Up @@ -64,6 +64,8 @@ Remarks:
* The exec dir is set to `$XDG_RUNTIME_DIR/docker` by default.
* The daemon config dir is set to `~/.config/docker` (not `~/.docker`, which is used by the client) by default.
* The `dockerd-rootless.sh` script executes `dockerd` in its own user, mount, and network namespaces. You can enter the namespaces by running `nsenter -U --preserve-credentials -n -m -t $(cat $XDG_RUNTIME_DIR/docker.pid)`.
* `docker info` shows `rootless` in `SecurityOptions`
* `docker info` shows `none` as `Cgroup Driver`

### Client

Expand Down

0 comments on commit 3d21b86

Please sign in to comment.