docker/docker — pull request #9436 by lhuard1A (2014-12-01 17:53:25+00:00)
Title: Add the possibility with docker to choose the parent slice of containers’ cgroup.

docker spawns the containers in their dedicated cgroup.
However, all the docker’s cgroups are created under `/system.slice`.
It may be interesting to have a more complex hierarchy.

For example, some tools implement the concept of “group of containers” aka POD, like fig or kubernetes. We can imagine to have a slice per POD and the containers cgroup be inside the slice of their POD.

This patch adds the `--slice` option to “`docker run`” that allows to specify in which parent slice a docker container must be spawned.

Ex:
```
# docker run -d -s system-kubernetes-podX.slice busybox sleep 1800

# systemd-cgls
|-1 /usr/lib/systemd/systemd
|-system.slice
| |-system-kubernetes.slice
| | `-system-kubernetes-podX.slice
| | `-docker-d8fc58071d684677b71dd733e3eea8dac17989bd39773705bbfb96649a00e4c1.scope
| | `-272 sleep 1800
```

libcontainer already contained what is needed for that in `vendor/src/github.com/docker/libcontainer/cgroups/systemd/apply_systemd.go`. Only docker had to be touched.

I tested that change on my PC and it worked as expected and as in the example above.
I tried to write a test in `docker_cli_run_test.go` but in the context created by `make test-integration-cli`, it didn’t work.
I suspect that it is because `make test-integration-cli` runs `docker_cli_run_test` inside a docker where there is no systemd running.