8

When I try to run a docker image I get the following error:

Error response from daemon: Cannot start container {id}: 
[8] System error: open /sys/fs/cgroup/cpu,cpuacct/init.scope/system.slice/docker-{id}.scope/cpu.shares: no such file or directory

/sys/fs/cgroup/cpu,cpuacct/ is mounted but there is no system.slice directory in init.scope

docker version:

Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

Kernel:

Linux christian-pc 4.1.0-2-amd64 #1 SMP Debian 4.1.6-1 (2015-08-23) x86_64 GNU/Linux

mounts (excerpt):

tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
/dev/sda1 on /boot type ext2 (rw,relatime)
/dev/mapper/christian--pc--vg-home on /home type ext4 (rw,relatime,data=ordered)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=814904k,mode=700,uid=1000,gid=1000)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

Any help is very much appreciated.

2

3 Answers 3

7

I had the same problem, and I found your question and also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798778, "systemd 226's init.scope breaks docker.io 1.7.1~dfsg1-1."

Wherein Dmitry Smirnov says you can add --exec-opt native.cgroupdriver=cgroupfs to DOCKER_OPTS in /etc/default/docker.

Worked for me.

2
  • Indeed, it's systemd 226 breaking cfgroups, using the cgroupfs driver with docker fixes it. After changing the values you need to restart the docker daemon for it to work.
    – ghostbar
    Commented Oct 1, 2015 at 15:57
  • I had to add that to the invocation of docker in /etc/systemd/system/multi-user.target.wants/docker.service, but otherwise it worked.
    – maddyblue
    Commented Nov 12, 2015 at 21:36
7

Changing DOCKER_OPTS to use cgroupfs as in Jared Jennings answer, may not be enough -- as there is another issue to check.

In a comment to docker issue 9889 "zepalmer" noted that the docker systemd entry could be configured in /lib/systemd/system/docker.service not to use the DOCKER_OPTS in /etc/default/docker. The consequence is that changing /etc/default/docker will be ineffective on how the daemon starts.

I found this issue was true in Ubuntu 16.04.2 LTS:

Looking in /lib/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target docker.socket
Requires=docker.socket

[Service]
ExecStart=/usr/bin/docker -d -H fd://
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity

[Install]
WantedBy=multi-user.target

this is the same contents reported by zepalmer.

After changing the "ExecStart" line in the service section with the following:

EnvironmentFile=/etc/default/docker
ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd://

and including --exec-opt native.cgroupdriver=cgroupfs in DOCKER_OPTS in /etc/default/docker, docker seems to be working normally again.

0

this save my day :)

  1. sudo dnf config-manager \ --add-repo \ https://download.docker.com/linux/fedora/docker-ce.repo
  2. sudo dnf -y install docker-ce
  3. sudo groupadd docker && sudo usermod -aG docker $USER
  4. sudo gedit /etc/default/grub
  5. GRUB_CMDLINE_LINUX add the parameter : systemd.unified_cgroup_hierarchy=0
  6. sudo grub2-mkconfig reboot

https://github.com/moby/moby/issues/33594

Not the answer you're looking for? Browse other questions tagged or ask your own question.