Browse code

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

info: report cgroup driver as "none" when running rootless

Sebastiaan van Stijn authored on 2019/06/04 05:46:08
Showing 4 changed files
... ...
@@ -3818,7 +3818,7 @@ definitions:
3818 3818
         description: |
3819 3819
           The driver to use for managing cgroups.
3820 3820
         type: "string"
3821
-        enum: ["cgroupfs", "systemd"]
3821
+        enum: ["cgroupfs", "systemd", "none"]
3822 3822
         default: "cgroupfs"
3823 3823
         example: "cgroupfs"
3824 3824
       NEventsListener:
... ...
@@ -4053,7 +4053,7 @@ definitions:
4053 4053
       SecurityOptions:
4054 4054
         description: |
4055 4055
           List of security features that are enabled on the daemon, such as
4056
-          apparmor, seccomp, SELinux, and user-namespaces (userns).
4056
+          apparmor, seccomp, SELinux, user-namespaces (userns), and rootless.
4057 4057
 
4058 4058
           Additional configuration options for each security feature may
4059 4059
           be present, and are included as a comma-separated list of key/value
... ...
@@ -4066,6 +4066,7 @@ definitions:
4066 4066
           - "name=seccomp,profile=default"
4067 4067
           - "name=selinux"
4068 4068
           - "name=userns"
4069
+          - "name=rootless"
4069 4070
       ProductLicense:
4070 4071
         description: |
4071 4072
           Reports a summary of the product license on the daemon.
... ...
@@ -73,6 +73,7 @@ const (
73 73
 	// constant for cgroup drivers
74 74
 	cgroupFsDriver      = "cgroupfs"
75 75
 	cgroupSystemdDriver = "systemd"
76
+	cgroupNoneDriver    = "none"
76 77
 
77 78
 	// DefaultRuntimeName is the default runtime to be used by
78 79
 	// containerd if none is specified
... ...
@@ -584,6 +585,9 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
584 584
 }
585 585
 
586 586
 func (daemon *Daemon) getCgroupDriver() string {
587
+	if daemon.Rootless() {
588
+		return cgroupNoneDriver
589
+	}
587 590
 	cgroupDriver := cgroupFsDriver
588 591
 
589 592
 	if UsingSystemd(daemon.configStore) {
... ...
@@ -610,6 +614,9 @@ func VerifyCgroupDriver(config *config.Config) error {
610 610
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
611 611
 		return nil
612 612
 	}
613
+	if cd == cgroupNoneDriver {
614
+		return fmt.Errorf("native.cgroupdriver option %s is internally used and cannot be specified manually", cd)
615
+	}
613 616
 	return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
614 617
 }
615 618
 
... ...
@@ -22,7 +22,11 @@ keywords: "API, Docker, rcli, REST, documentation"
22 22
   `private` to create the container in its own private cgroup namespace.  The per-daemon
23 23
   default is `host`, and can be changed by using the`CgroupNamespaceMode` daemon configuration
24 24
   parameter.
25
-
25
+* `GET /info` now includes `name=rootless` in `SecurityOptions` when the daemon is running in
26
+  rootless mode.  This change is not versioned, and affects all API versions if the daemon has
27
+  this patch.
28
+* `GET /info` now returns `none` as `CgroupDriver` when the daemon is running in rootless mode.
29
+  This change is not versioned, and affects all API versions if the daemon has this patch.
26 30
 
27 31
 ## v1.40 API changes
28 32
 
... ...
@@ -64,6 +64,8 @@ Remarks:
64 64
 * The exec dir is set to `$XDG_RUNTIME_DIR/docker` by default.
65 65
 * The daemon config dir is set to `~/.config/docker` (not `~/.docker`, which is used by the client) by default.
66 66
 * 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)`.
67
+* `docker info` shows `rootless` in `SecurityOptions`
68
+* `docker info` shows `none` as `Cgroup Driver`
67 69
 
68 70
 ### Client
69 71