ibuildthecloud / systemd-docker

Wrapper for "docker run" to handle systemd quirks
Apache License 2.0
720 stars 111 forks source link

Docker daemon is moved to service's slice #27

Open plietar opened 9 years ago

plietar commented 9 years ago

Hi, On a debian freshly upgraded to jessie, using the example unit file from the Quick Usage section causes systemd-docker to move the docker daemon itself to the new cgroup.

For example (The outputs have been shortened):

$ sudo systemctl status
● nuc
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sun 2015-04-26 18:50:16 CEST; 1 day 16h ago
   CGroup: /
           ├─1 /sbin/init
           └─system.slice
             [...]
             ├─docker.service
             │ └─26127 /usr/bin/docker -d -H fd://
             [...]
$ sudo systemctl start nginx
$ sudo systemctl status
● nuc
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sun 2015-04-26 18:50:16 CEST; 1 day 16h ago
   CGroup: /
           ├─1 /sbin/init
           └─system.slice
             [...]
             ├─nginx.service
             │ ├─26127 /usr/bin/docker -d -H fd://
             │ ├─26164 /usr/local/bin/systemd-docker --cgroups name=systemd run --rm --name nginx.service nginx
             │ ├─26177 nginx: master process nginx -g daemon off
             │ └─26201 nginx: worker proces
             [...]
$ sudo journalctl -u nginx.service
[...]
Apr 28 12:08:34 nuc systemd[1]: nginx.service: Supervising process 26177 which is not our child. We'll most likely not notice when it exits.
Apr 28 12:08:34 nuc systemd-docker[26164]: 2015/04/28 12:08:34 Moving pid 26127 to /sys/fs/cgroup/systemd/system.slice/nginx.service/cgroup.procs
Apr 28 12:08:34 nuc systemd-docker[26164]: 2015/04/28 12:08:34 Moving pid 26177 to /sys/fs/cgroup/systemd/system.slice/nginx.service/cgroup.procs
Apr 28 12:08:34 nuc docker[26127]: time="2015-04-28T12:08:34+02:00" level=info msg="GET /v1.11/version"
Apr 28 12:08:34 nuc docker[26127]: time="2015-04-28T12:08:34+02:00" level=info msg="+job version()"
Apr 28 12:08:34 nuc docker[26127]: time="2015-04-28T12:08:34+02:00" level=info msg="-job version() = OK (0)"
Apr 28 12:08:34 nuc docker[26127]: time="2015-04-28T12:08:34+02:00" level=info msg="GET /v1.11/version"
Apr 28 12:08:34 nuc docker[26127]: time="2015-04-28T12:08:34+02:00" level=info msg="+job version()"
[...]
$ cat /sys/fs/cgroup/systemd/system.slice/docker.service/cgroup.procs
$ cat /sys/fs/cgroup/systemd/system.slice/nginx.service/cgroup.procs
26127
26164
26177
26201

This is using --cgroups name=systemd. It behaves the same way without it. If other containers are running, they get moved as well.

systemd comes from the official debian repositories, docker from the get.docker.io one

$ systemctl --version
systemd 215
+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR
$ docker version
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 4749651
OS/Arch (client): linux/amd64
Server version: 1.6.0
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 4749651
OS/Arch (server): linux/amd64