dotcloud/docker — pull request #4450 by alexlarsson (2014-03-04 14:53:27+00:00)
Title: Add systemd implementation of cgroups

The raw filesystem cgroup API is scheduled for removal for generic userspace (write) access, and some other changes. Long term all modifications of the cgroup tree has to be done via a userspace API to a single process that does the cgroup tree writes. For systems using systemd as pid 1 the API to use is the systemd manager APIs for slices (directories in the cgroup tree) and scopes (transient systemd units)

This patch set adds some code to talk to systemd and uses systemd slices and scopes to implement the cgroups api that the native execdriver uses.

Not only does this give the cgroup support, but it exposes the container as a systemd unit which you can see and manage with systemd tools, as well as get info about in other tools like ps::
```
$ systemd-cgls
...
└─system.slice
├─system-docker.slice
│ ├─docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope
│ │ └─3989 sh
│ └─docker-e160a6955208fa7edabb1694762b0757adc64425f7d1c5a86fb0b1c3676a04bb.scope
│ └─3114 bash
...

$ ps -eo pid,user,args,unit
...
3114 root bash docker-e160a6955208fa7edabb1694762b0757adc64425f7d1c5a86fb0b1c3676a04bb.scope
3989 root sh docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope
...

$ systemctl status -l docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope
docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope - docker container d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef
Loaded: loaded (/run/systemd/system/docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope; static)
Drop-In: /run/systemd/system/docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope.d
└─90-Description.conf, 90-DeviceAllow.conf, 90-DevicePolicy.conf, 90-Slice.conf
Active: active (running) since tis 2014-03-04 15:49:37 CET; 2min 23s ago
CGroup: /system.slice/system-docker.slice/docker-d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.scope
└─3989 sh

mar 04 15:49:37 localhost.localdomain systemd[1]: Started docker container d6b15f04feb95083acea4b9caa6e59f8ebe67e3e3cf9cb8c59fad543490ee3ef.

```