如何修复“docker:来自守护程序的错误响应:cgroups:找不到 cgroup 安装目的地:未知。” 在“docker run”上?

N0r*_*ert 7 lxc cgroup docker lxd 16.04

我安装了 Ubuntu 16.04.6 LTS。

之前我已经从其存储库将 Docker 安装为docker.io包。

昨天我用 LXD 安装了 LXC,我想它们与 Docker 共存存在一些问题。

LXC正常工作:

$ lxc exec ubuntu-test -- su --login
ubuntu-test ~ # 
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试启动 docker 容器时,docker run出现错误:

docker: Error response from daemon: cgroups: cannot find cgroup mount destination: unknown.
Run Code Online (Sandbox Code Playgroud)

如何通过启动 Docker 容器来解决此问题?
如果可能,请建议同时安装 Docker 和 LXC/LXD 的解决方案。


一些调试信息:

$ mount | grep cgroup
tmpfs on /sys/fs/cgroup type tmpfs (rw,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)
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/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,clone_children)
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/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event,release_agent=/run/cgmanager/agents/cgm-release-agent.perf_event)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids,release_agent=/run/cgmanager/agents/cgm-release-agent.pids)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb,release_agent=/run/cgmanager/agents/cgm-release-agent.hugetlb)

$ dpkg -l | grep -E "containerd|docker|lxc|lxd|cgroup"
ii  cgmanager                                     0.39-2ubuntu5                                   amd64        Central cgroup manager daemon
ii  cgroup-lite                                   1.11                                            all          Light-weight package to set up cgroups at system boot
ii  containerd                                    1.2.6-0ubuntu1~16.04.3                          amd64        daemon to control runC
ii  docker.io                                     18.09.7-0ubuntu1~16.04.5                        amd64        Linux container runtime
ii  libcgmanager0:amd64                           0.39-2ubuntu5                                   amd64        Central cgroup manager daemon (client library)
ii  liblxc1                                       2.0.11-0ubuntu1~16.04.3                         amd64        Linux Containers userspace tools (library)
ii  libpam-cgfs                                   2.0.8-0ubuntu1~16.04.2                          amd64        PAM module for managing cgroups for LXC
ii  lxc-common                                    2.0.11-0ubuntu1~16.04.3                         amd64        Linux Containers userspace tools (common tools)
ii  lxc-templates                                 2.0.11-0ubuntu1~16.04.3                         amd64        Linux Containers userspace tools (templates)
ii  lxc1                                          2.0.11-0ubuntu1~16.04.3                         amd64        Linux Containers userspace tools
ii  lxcfs                                         2.0.8-0ubuntu1~16.04.2                          amd64        FUSE based filesystem for LXC
ii  lxd                                           2.0.11-0ubuntu1~16.04.4                         amd64        Container hypervisor based on LXC - daemon
ii  lxd-client                                    2.0.11-0ubuntu1~16.04.4                         amd64        Container hypervisor based on LXC - client
ii  python3-lxc                                   2.0.11-0ubuntu1~16.04.3                         amd64        Linux Containers userspace tools (Python 3.x bindings)

$ systemctl list-units --type service
  UNIT                                                      LOAD   ACTIVE     SUB     JOB   DESCRIPTION
  accounts-daemon.service                                   loaded active     running       Accounts Service
  acpid.service                                             loaded active     running       ACPI event daemon
  alsa-restore.service                                      loaded active     exited        Save/Restore Sound Card State
  apparmor.service                                               loaded active exited  LSB: AppArmor initialization
  apport.service                                            loaded active     exited        LSB: automatic crash report generation
  atd.service                                               loaded active     running       Deferred execution scheduler
  avahi-daemon.service                                      loaded active     running       Avahi mDNS/DNS-SD Stack
  avahi-dnsconfd.service                                    loaded active     running       Avahi DNS Configuration Daemon
  binfmt-support.service                                    loaded active     exited        Enable support for additional executable binary formats
  bluetooth.service                                         loaded active     running       Bluetooth service
  cgmanager.service                                         loaded active     running       Cgroup management daemon
  cgroupfs-mount.service                                    loaded active     exited        LSB: Set up cgroupfs mounts.
  click-system-hooks.service                                loaded active     exited        Run Click system-level hooks
  colord.service                                            loaded active     running       Manage, Install and Generate Color Profiles
  console-kit-daemon.service                                loaded active     running       Console Manager
  console-kit-log-system-start.service                      loaded active     exited        Console System Startup Logging
  console-setup.service                                     loaded active     exited        Set console font and keymap
  containerd.service                                        loaded active     running       containerd container runtime
  cpufrequtils.service                                      loaded active     exited        LSB: set CPUFreq kernel parameters
  cron.service                                              loaded active     running       Regular background program processing daemon
  cups-browsed.service                                      loaded active     running       Make remote CUPS printers available locally
  cups.service                                              loaded active     running       CUPS Scheduler
  dbus.service                                              loaded active     running       D-Bus System Message Bus
  docker.service                                            loaded inactive   dead    start Docker Application Container Engine
  ebtables.service                                          loaded active     exited        LSB: ebtables ruleset management
  getty@tty1.service                                        loaded inactive   dead    start Getty on tty1
  gpm.service                                               loaded active     running       LSB: gpm sysv init script
  gpsd.service                                              loaded active     running       GPS (Global Positioning System) Daemon
  grub-common.service                                       loaded active     exited        LSB: Record successful boot for GRUB
  hddtemp.service                                           loaded inactive   dead    start LSB: disk temperature monitoring daemon
  iio-sensor-proxy.service                                  loaded active     running       IIO Sensor Proxy service
  inetd.service                                             loaded active     running       Internet superserver
  irqbalance.service                                        loaded active     running       LSB: daemon to balance interrupts for SMP systems
  keyboard-setup.service                                    loaded active     exited        Set console keymap
  kmod-static-nodes.service                                 loaded active     exited        Create list of required static device nodes for the curre
  libvirt-bin.service                                       loaded active     running       Virtualization daemon
  libvirt-guests.service                                    loaded active     exited        Suspend Active Libvirt Guests
  lightdm.service                                           loaded active     running       Light Display Manager
  lm-sensors.service                                        loaded active     exited        Initialize hardware monitoring sensors
  loadcpufreq.service                                       loaded active     exited        LSB: Load kernel modules needed to enable cpufreq scaling
  lvm2-lvmetad.service                                      loaded active     running       LVM2 metadata daemon
  lvm2-monitor.service                                      loaded active     exited        Monitoring of LVM2 mirrors, snapshots etc. using dmeventd
  lxc-net.service                                           loaded inactive   dead    start LXC network bridge setup
  lxc.service                                               loaded inactive   dead    start LXC Container Initialization and Autoboot Code
  lxcfs.service                                             loaded active     running       FUSE filesystem for LXC
  lxd-bridge.service                                        loaded active     exited        LXD - network bridge
  lxd-containers.service                                    loaded activating start   start LXD - container startup/shutdown
  lxd.service                                               loaded inactive   dead    start LXD - main daemon
  mdadm.service                                             loaded active     running       LSB: MD monitoring daemon
  ModemManager.service                                      loaded active     running       Modem Manager
  networking.service                                        loaded active     exited        Raise network interfaces
  NetworkManager-wait-online.service                        loaded activating start   start Network Manager Wait Online
  NetworkManager.service                                    loaded active     running       Network Manager
  nfs-config.service                                        loaded active     exited        Preprocess NFS configuration
  nmbd.service                                              loaded inactive   dead    start LSB: start Samba NetBIOS nameserver (nmbd)
  ntp.service                                               loaded inactive   dead    start LSB: Start NTP daemon
  ofono.service                                             loaded active     running       oFono Mobile telephony stack
  ondemand.service                                          loaded active     running       LSB: Set the CPU Frequency Scaling governor to "ondemand"
  openvpn.service                                           loaded active     exited        OpenVPN service
  osspd.service                                             loaded active     running       OSS Proxy Daemon
  plymouth-quit-wait.service                                loaded inactive   dead    start Hold until boot process finishes up
  polipo.service                                            loaded active     running       LSB: Start or stop the polipo web cache
  polkitd.service                                           loaded active     running       Authenticate and Authorize Users to Run Privileged Tasks
  postgresql.service                                        loaded active     exited        PostgreSQL RDBMS
  qemu-kvm.service                                          loaded active     exited        LSB: QEMU KVM module loading script
  rc-local.service                                          loaded inactive   dead    start /etc/rc.local Compatibility
  resolvconf.service                                        loaded active     exited        Nameserver information manager
  rsyslog.service                                           loaded active     running       System Logging Service
  rtkit-daemon.service                                      loaded active     running       RealtimeKit Scheduling Policy Service
  samba-ad-dc.service                                       loaded inactive   dead    start LSB: start Samba daemons for the AD DC
  schroot.service                                           loaded inactive   dead    start LSB: Recover schroot sessions.
  setvtrgb.service                                          loaded inactive   dead    start Set console scheme
  smartd.service                                            loaded active     running       Self Monitoring and Reporting Technology (SMART) Daemon
  smbd.service                                              loaded inactive   dead    start LSB: start Samba SMB/CIFS daemon (smbd)
  speech-dispatcher.service                                 loaded active     exited        LSB: Speech Dispatcher
  ssh.service                                               loaded active     running       OpenBSD Secure Shell server
  sysstat.service                                           loaded active     exited        LSB: Start/stop sysstat's sadc
  systemd-backlight@backlight:intel_backlight.service       loaded active     exited        Load/Save Screen Backlight Brightness of backlight:intel_
  systemd-backlight@leds:asus::kbd_backlight.service        loaded active     exited        Load/Save Screen Backlight Brightness of leds:asus::kbd_b
  systemd-fsck@dev-disk-by\x2duuid-1207\x2d4052.service     loaded active     exited        File System Check on /dev/disk/by-uuid/1207-4052
  systemd-fsck@dev-disk-by\x2duuid-4a44edd5\x2dd396\x2d443e\x2d9a6a\x2d41a81be97246.service loaded active     exited        File System Check on /dev/disk/by-uuid/4a44edd5-d396-443e
  systemd-fsckd.service                                     loaded active     running       File System Check Daemon to report status
  systemd-hostnamed.service                                 loaded active     running       Hostname Service
  systemd-journal-flush.service                             loaded active     exited        Flush Journal to Persistent Storage
  systemd-journald.service                                  loaded active     running       Journal Service
  systemd-logind.service                                    loaded active     running       Login Service
  systemd-modules-load.service                              loaded active     exited        Load Kernel Modules
  systemd-random-seed.service                               loaded active     exited        Load/Save Random Seed
  systemd-remount-fs.service                                loaded active     exited        Remount Root and Kernel File Systems
  systemd-sysctl.service                                    loaded active     exited        Apply Kernel Variables
  systemd-tmpfiles-setup-dev.service                        loaded active     exited        Create Static Device Nodes in /dev
  systemd-tmpfiles-setup.service                            loaded active     exited        Create Volatile Files and Directories
  systemd-udev-trigger.service                              loaded active     exited        udev Coldplug all Devices
  systemd-udevd.service                                     loaded active     running       udev Kernel Device Manager
  systemd-update-utmp-runlevel.service                      loaded inactive   dead    start Update UTMP about System Runlevel Changes
  systemd-update-utmp.service                               loaded active     exited        Update UTMP about System Boot/Shutdown
  systemd-user-sessions.service                             loaded active     exited        Permit User Sessions
  sysvinit-backlight.service                                loaded active     exited        LSB: Save and restore screen and keyboard backlight level
  thermald.service                                          loaded active     running       Thermal Daemon Service
  timidity.service                                          loaded active     running       LSB: start and stop timidity
  tor.service                                               loaded active     exited        Anonymizing overlay network for TCP (multi-instance-maste
  tor@default.service                                       loaded active     running       Anonymizing overlay network for TCP
  ubuntu-fan.service                                        loaded inactive   dead    start Ubuntu FAN network setup
  udisks.service                                            loaded active     running       Disk Manager (legacy version)
  udisks2.service                                           loaded active     running       Disk Manager
  ufw.service                                               loaded active     exited        Uncomplicated firewall
  upower.service                                            loaded active     running       Daemon for power management
  user@1000.service                                         loaded active     running       User Manager for UID 1000
  user@104.service                                          loaded active     running       User Manager for UID 104
  vboxautostart-service.service                             loaded active     exited        vboxautostart-service.service
  vboxballoonctrl-service.service                           loaded active     exited        vboxballoonctrl-service.service
  vboxdrv.service                                           loaded active     exited        VirtualBox Linux kernel module
  vboxweb-service.service                                   loaded active     running       vboxweb-service.service
  whoopsie.service                                          loaded inactive   dead    start crash report submission daemon
  winbind.service                                           loaded inactive   dead    start LSB: start Winbind daemon
  wpa_supplicant.service                                    loaded active     running       WPA supplicant

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
JOB    = Pending job for the unit.

116 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

Run Code Online (Sandbox Code Playgroud)

删除所有镜像和容器并添加-D到 docker 服务后更新:

$ docker run -it ubuntu:18.04 
Unable to find image 'ubuntu:18.04' locally
18.04: Pulling from library/ubuntu
35c102085707: Pull complete 
251f5509d51d: Pull complete 
8e829fe70a46: Pull complete 
6001e1789921: Pull complete 
Digest: sha256:d1d454df0f579c6be4d8161d227462d69e163a8ff9d20a847533989cf0c94d90
Status: Downloaded newer image for ubuntu:18.04
docker: Error response from daemon: cgroups: cannot find cgroup mount destination: unknown.

$ tail -f /var/log/syslog | grep docker
Sep  7 20:57:34 norbert-UX32A dockerd[29727]: time="2019-09-07T20:57:34.235977407+03:00" level=debug msg="Calling GET /_ping"
Sep  7 20:57:34 norbert-UX32A dockerd[29727]: time="2019-09-07T20:57:34.239220453+03:00" level=debug msg="Calling POST /v1.39/containers/create"
Sep  7 20:57:34 norbert-UX32A dockerd[29727]: time="2019-09-07T20:57:34.239802159+03:00" level=debug msg="form data: {\"AttachStderr\":true,\"AttachStdin\":true,\"AttachStdout\":true,\"Cmd\":null,\"Domainname\":\"\",\"Entrypoint\":null,