docker cannot start container ... cpu.shares: no such file or directory

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.


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.

Tags:

Docker

Debian