apt升级后docker无法启动(社区版)

apt升级后docker无法启动(社区版)

docker-ce使用 pygrub 在 XEN 上的虚拟机内更新了我的 debian 10。

升级后我升级到 Debian 11,但错误仍然存​​在。

我现在使用 docker-ce 版本 5:23.0.0-1~debian.11~bullseye,在尝试重新启动守护进程时收到此错误消息:

Starting Docker Application Container Engine...
level=warning msg="failed to rename /var/lib/docker/tmp for background deletion: rename /var/lib/docker/tmp /var/lib/docker/tmp-old: file exists. Del
eting synchronously" [Channel #1] Channel created" module=grpc                                                                                     
[Channel #1] original dial target is: \"unix:///run/containerd/containerd.sock\"" module=grpc                                 
[Channel #1] parsed dial target is: {Scheme:unix Authority: Endpoint:run/containerd/containerd.sock URL:{Scheme:unix Opaque: U
ser: Host: Path:/run/containerd/containerd.sock RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}" module=grpc [Channel #1] Channel authority set to \"localhost\"" module=grpc                                                              
[Channel #1] Resolver state updated: {\n  \"Addresses\": [\n    {\n      \"Addr\": \"/run/containerd/containerd.sock\",\n \"ServerName\": \"\",\n      \"Attributes\": {},\n      \"BalancerAttributes\": null,\n      \"Type\": 0,\n      \"Metadata\": null\n    }\n  ],\n  \"ServiceConfig\": null,\n  \"Attributes\": null\n} (resolver returned new addresses)" module=grpc [Channel #1] Channel switches to new LB policy \"pick_first\"" module=grpc
[Channel #1 SubChannel #2] Subchannel created" module=grpc                                                           [8/13043]
[Channel #1 SubChannel #2] Subchannel Connectivity change to CONNECTING" module=grpc                                          
[Channel #1 SubChannel #2] Subchannel picks a new address \"/run/containerd/containerd.sock\" to connect" module=grpc         
[Channel #1] Channel Connectivity change to CONNECTING" module=grpc                                                           
[Channel #1 SubChannel #2] Subchannel Connectivity change to READY" module=grpc                                               
[Channel #1] Channel Connectivity change to READY" module=grpc                                                                
[Channel #4] Channel created" module=grpc                                                                                     
[Channel #4] original dial target is: \"unix:///run/containerd/containerd.sock\"" module=grpc                                 
[Channel #4] parsed dial target is: {Scheme:unix Authority: Endpoint:run/containerd/containerd.sock URL:{Scheme:unix Opaque: $
ser: Host: Path:/run/containerd/containerd.sock RawPath: OmitHost:false ForceQuery:false RawQuery: Fragment: RawFragment:}}" module=grpc                                                                                            
[Channel #4] Channel authority set to \"localhost\"" module=grpc
[Channel #4] Resolver state updated: {\n  \"Addresses\": [\n    {\n      \"Addr\": \"/run/containerd/containerd.sock\",\n
 \"ServerName\": \"\",\n      \"Attributes\": {},\n      \"BalancerAttributes\": null,\n      \"Type\": 0,\n      \"Metadata\": null\n    }\n  ],\n  \"ServiceConfig\": null,\n  \"Attributes\": null\n} (resolver returned new addr$
sses)" module=grpc
[Channel #4] Channel switches to new LB policy \"pick_first\"" module=grpc
[Channel #4 SubChannel #5] Subchannel created" module=grpc
[Channel #4 SubChannel #5] Subchannel Connectivity change to CONNECTING" module=grpc
[Channel #4 SubChannel #5] Subchannel picks a new address \"/run/containerd/containerd.sock\" to connect" module=grpc
[Channel #4] Channel Connectivity change to CONNECTING" module=grpc
[Channel #4 SubChannel #5] Subchannel Connectivity change to READY" module=grpc
[Channel #4] Channel Connectivity change to READY" module=grpc
level=warning msg="Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docked` to refer to dm.thinpooldev section." storage-driver=devicemapper
level=warning msg="Base device already exists and has filesystem ext4 on it. User specified filesystem  will be ignored." storage-driver=devicemapper
level=error msg="[graphdriver] prior storage driver devicemapper is deprecated and will be removed in a future release; update the the daemon configuration and explicitly choose this storage driver to continue using it; visit https://docs.docker.com/go/storage-driver/ for more information"
[Channel #1] Channel Connectivity change to SHUTDOWN" module=grpc
[Channel #1 SubChannel #2] Subchannel Connectivity change to SHUTDOWN" module=grpc
[Channel #1 SubChannel #2] Subchannel deleted" module=grpc
[Channel #1] Channel deleted" module=grpc
failed to start daemon: error initializing graphdriver: prior storage driver devicemapper is deprecated and will be removed in a future release; update the the daemon configuration and explic$
tly choose this storage driver to continue using it; visit https://docs.docker.com/go/storage-driver/ for more information

这里的主要错误消息是什么?我猜:

存储驱动程序 devicemapper 已弃用

我尝试像这样编辑/lib/systemd/system/docker.service添加:--storage-opt dm.thinpooldev

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --storage-opt dm.thinpooldev

然后调用systemctl daemon-reload,但这没有帮助,似乎--storage-opt dm.thinpooldevDocker Community Edition (CE) 版本 5:23.0.0-1 不支持该选项。

答案1

存储驱动程序devicemapper已弃用并在上次更新中被禁用。您应该将存储驱动程序设置为overlay2.

打开该文件/etc/docker/daemon.json(如果不存在,则创建它)并添加以下 JSON 字符串:

{
  "storage-driver": "overlay2"
}

然后重启docker:

systemctl restart docker

注意力!现有容器无法在存储驱动程序更改后继续存在,因此您必须重新运行docker-compose将使用新驱动程序重建容器的所有文件。

答案2

我没有走这条路所以这是未经测试的。如果这对您有用,请在这里反馈我。

如果您迫切需要旧容器,因为里面有数据没有作为卷安装,您可以在服务文件中重新启用旧存储驱动程序:/lib/systemd/system/docker.service

更改ExecStart行并添加--storage-driver devicemapper例如:

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --storage-driver devicemapper

然后

systemctl daemon-reload; systemctl restart docker

相关内容