Browse code

Merge pull request #255 from thaJeztah/19.03_backport_ro_none_cgroupdriver

[19.03 backport] info: report cgroup driver as "none" when running rootless

Sebastiaan van Stijn authored on 2019/06/05 01:41:58
Showing 4 changed files
... ...
@@ -3805,7 +3805,7 @@ definitions:
3805 3805
         description: |
3806 3806
           The driver to use for managing cgroups.
3807 3807
         type: "string"
3808
-        enum: ["cgroupfs", "systemd"]
3808
+        enum: ["cgroupfs", "systemd", "none"]
3809 3809
         default: "cgroupfs"
3810 3810
         example: "cgroupfs"
3811 3811
       NEventsListener:
... ...
@@ -4040,7 +4040,7 @@ definitions:
4040 4040
       SecurityOptions:
4041 4041
         description: |
4042 4042
           List of security features that are enabled on the daemon, such as
4043
-          apparmor, seccomp, SELinux, and user-namespaces (userns).
4043
+          apparmor, seccomp, SELinux, user-namespaces (userns), and rootless.
4044 4044
 
4045 4045
           Additional configuration options for each security feature may
4046 4046
           be present, and are included as a comma-separated list of key/value
... ...
@@ -4053,6 +4053,7 @@ definitions:
4053 4053
           - "name=seccomp,profile=default"
4054 4054
           - "name=selinux"
4055 4055
           - "name=userns"
4056
+          - "name=rootless"
4056 4057
       ProductLicense:
4057 4058
         description: |
4058 4059
           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
... ...
@@ -575,6 +576,9 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
575 575
 }
576 576
 
577 577
 func (daemon *Daemon) getCgroupDriver() string {
578
+	if daemon.Rootless() {
579
+		return cgroupNoneDriver
580
+	}
578 581
 	cgroupDriver := cgroupFsDriver
579 582
 
580 583
 	if UsingSystemd(daemon.configStore) {
... ...
@@ -601,6 +605,9 @@ func VerifyCgroupDriver(config *config.Config) error {
601 601
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
602 602
 		return nil
603 603
 	}
604
+	if cd == cgroupNoneDriver {
605
+		return fmt.Errorf("native.cgroupdriver option %s is internally used and cannot be specified manually", cd)
606
+	}
604 607
 	return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
605 608
 }
606 609
 
... ...
@@ -49,6 +49,11 @@ keywords: "API, Docker, rcli, REST, documentation"
49 49
 * `GET /info` now returns information about `DataPathPort` that is currently used in swarm
50 50
 * `GET /info` now returns `PidsLimit` boolean to indicate if the host kernel has
51 51
   PID limit support enabled.
52
+* `GET /info` now includes `name=rootless` in `SecurityOptions` when the daemon is running in
53
+  rootless mode.  This change is not versioned, and affects all API versions if the daemon has
54
+  this patch.
55
+* `GET /info` now returns `none` as `CgroupDriver` when the daemon is running in rootless mode.
56
+  This change is not versioned, and affects all API versions if the daemon has this patch.
52 57
 * `POST /containers/create` now accepts `DeviceRequests` as part of `HostConfig`.
53 58
   Can be used to set Nvidia GPUs.
54 59
 * `GET /swarm` endpoint now returns DataPathPort info
... ...
@@ -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