소스 검색

Merge pull request #39299 from AkihiroSuda/ro-none-cgroupdriver

info: report cgroup driver as "none" when running rootless
Sebastiaan van Stijn 6 년 전
부모
커밋
3d21b86e0a
4개의 변경된 파일17개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 2
      api/swagger.yaml
  2. 7 0
      daemon/daemon_unix.go
  3. 5 1
      docs/api/version-history.md
  4. 2 0
      docs/rootless.md

+ 3 - 2
api/swagger.yaml

@@ -3818,7 +3818,7 @@ definitions:
         description: |
         description: |
           The driver to use for managing cgroups.
           The driver to use for managing cgroups.
         type: "string"
         type: "string"
-        enum: ["cgroupfs", "systemd"]
+        enum: ["cgroupfs", "systemd", "none"]
         default: "cgroupfs"
         default: "cgroupfs"
         example: "cgroupfs"
         example: "cgroupfs"
       NEventsListener:
       NEventsListener:
@@ -4053,7 +4053,7 @@ definitions:
       SecurityOptions:
       SecurityOptions:
         description: |
         description: |
           List of security features that are enabled on the daemon, such as
           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
           Additional configuration options for each security feature may
           be present, and are included as a comma-separated list of key/value
           be present, and are included as a comma-separated list of key/value
@@ -4066,6 +4066,7 @@ definitions:
           - "name=seccomp,profile=default"
           - "name=seccomp,profile=default"
           - "name=selinux"
           - "name=selinux"
           - "name=userns"
           - "name=userns"
+          - "name=rootless"
       ProductLicense:
       ProductLicense:
         description: |
         description: |
           Reports a summary of the product license on the daemon.
           Reports a summary of the product license on the daemon.

+ 7 - 0
daemon/daemon_unix.go

@@ -73,6 +73,7 @@ const (
 	// constant for cgroup drivers
 	// constant for cgroup drivers
 	cgroupFsDriver      = "cgroupfs"
 	cgroupFsDriver      = "cgroupfs"
 	cgroupSystemdDriver = "systemd"
 	cgroupSystemdDriver = "systemd"
+	cgroupNoneDriver    = "none"
 
 
 	// DefaultRuntimeName is the default runtime to be used by
 	// DefaultRuntimeName is the default runtime to be used by
 	// containerd if none is specified
 	// containerd if none is specified
@@ -584,6 +585,9 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
 }
 }
 
 
 func (daemon *Daemon) getCgroupDriver() string {
 func (daemon *Daemon) getCgroupDriver() string {
+	if daemon.Rootless() {
+		return cgroupNoneDriver
+	}
 	cgroupDriver := cgroupFsDriver
 	cgroupDriver := cgroupFsDriver
 
 
 	if UsingSystemd(daemon.configStore) {
 	if UsingSystemd(daemon.configStore) {
@@ -610,6 +614,9 @@ func VerifyCgroupDriver(config *config.Config) error {
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
 		return nil
 		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)
 	return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
 }
 }
 
 

+ 5 - 1
docs/api/version-history.md

@@ -22,7 +22,11 @@ keywords: "API, Docker, rcli, REST, documentation"
   `private` to create the container in its own private cgroup namespace.  The per-daemon
   `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
   default is `host`, and can be changed by using the`CgroupNamespaceMode` daemon configuration
   parameter.
   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
 ## v1.40 API changes
 
 

+ 2 - 0
docs/rootless.md

@@ -64,6 +64,8 @@ Remarks:
 * The exec dir is set to `$XDG_RUNTIME_DIR/docker` by default.
 * 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 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)`.
 * 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
 ### Client