Docker 20.10.x 使系统在关闭或重新启动之前等待几分钟

Foo*_*Bar 13 shutdown debian systemd reboot docker

我已成功将 Debian buster 升级到最新版本(Bullseye),之后,每当我想要重新启动或关闭它时,都需要几分钟才能完成,同时等待某些进程完成并显示以下消息:

watchdog: watchdog0: watchdog did not stop!
systemd-shutdown[1]: Syncing filesystem and block devices.
systemd-shutdown[1]: Sending SIGTERM to remaining process...
systemd-journald[372]: Received SIGTERM from PID 1 (systemd-shutdown).
systemd-shutdown[1]: waiting for process: containerd-shim.
Run Code Online (Sandbox Code Playgroud)

我的系统上安装了 docker,这似乎是问题的原因。

$ ps aux | grep containerd-shim
root        3420  0.0  0.1 1451744 21876 ?       Sl   11:07   0:00 /usr/bin/containerd-shim-runc-v2 -namespace moby -id 0dd6b89a62d...66cc5c0a44b6f01d77c -address /run/containerd/containerd.sock

$ dpkg -S /usr/bin/containerd-shim-runc-v2 
containerd: /usr/bin/containerd-shim-runc-v2

$ aptitude why containerd
i   docker.io Depends containerd
Run Code Online (Sandbox Code Playgroud)

我尝试在重新启动系统之前停止泊坞窗的服务/套接字。没有改变。

知道如何解决这个问题吗?


$ docker version
Client:
 Version:           20.10.5+dfsg1
 API version:       1.41
 Go version:        go1.15.9
 Git commit:        55c4c88
 Built:             Wed Aug  4 19:55:57 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.5+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.15.9
  Git commit:       363e9a8
  Built:            Wed Aug  4 19:55:57 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.5~ds1
  GitCommit:        1.4.5~ds1-2
 runc:
  Version:          1.0.0~rc93+ds1
  GitCommit:        1.0.0~rc93+ds1-5+b2
 docker-init:
  Version:          0.19.0
  GitCommit:        
Run Code Online (Sandbox Code Playgroud)

you*_*ufu 9

如果您使用实时恢复,那么这是 containerd shim v2 的一个已知问题。已在containerd \xe2\x89\xa5 1.6.0-rc.2 中修复。向后移植到 Containerd 1.5.10。Docker 引擎 20.10.13 中已修复。

\n\n

解决方法:

\n
    \n
  1. 使用 shim v1 而不是 v2

    \n

    指定特定容器的运行时

    \n
    docker run --runtime=io.containerd.runtime.v1.linux ...`\n
    Run Code Online (Sandbox Code Playgroud)\n

    或者设置系统范围的默认运行时

    \n
    # cat /etc/docker/daemon.json\n{\n    "default-runtime": "io.containerd.runtime.v1.linux",\n    "live-restore": true\n}\n
    Run Code Online (Sandbox Code Playgroud)\n

    警告:shim v1 已弃用,并将在下一个 Docker 版本中删除。\n警告:shim v1 不适用于 cgroups v2

    \n
  2. \n
  3. 在重新启动/关闭之前使用 systemd 服务终止容器

    \n
    # /etc/systemd/system/containerd-shim-v2-workaround.service\n[Unit]\nDescription=containerd-shim v2 workaround\nBefore=docker.service\nRequires=containerd.service\nAfter=containerd.service\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStop=-/bin/sh -c \'[ "$(systemctl is-system-running)" = "stopping" ] || exit 0; ctr -n moby tasks ls -q | xargs -r -L1 ctr -n moby tasks kill; ctr -n moby containers ls -q | xargs -r ctr -n moby containers rm\'\n\n[Install]\nWantedBy=containerd.service\n
    Run Code Online (Sandbox Code Playgroud)\n

    我将其发布在 moby 问题线程下。但这可能并不适合所有用例。谨慎使用。

    \n
  4. \n
\n