当Docker守护程序无法启动时,我所做的是
当我更新系统的软件包(使用yum update)后,导致Docker无法使用,因此我将其记录在备忘录中。如果发现任何错误,请指出。
本次的环境是以下的状况。
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
当我将Docker版本从20.10.17更新到23.0.6,内核从3.10.0-1160.76更新到3.10.0-1160.90时出现了问题。
sudo yum history info xx
...
更新 docker-ce-3:20.10.17-3.el7.x86_64 @docker-ce-stable
更新 3:23.0.6-1.el7.x86_64 @docker-ce-stable
...
インストール kernel-3.10.0-1160.90.1.el7.x86_64 @updates
更新 kernel-debug-devel-3.10.0-1160.76.1.el7.x86_64 @updates
更新 3.10.0-1160.90.1.el7.x86_64 @updates
インストール kernel-devel-3.10.0-1160.90.1.el7.x86_64 @updates
...
由于Docker守护进程(dockerd)未启动,我尝试启动它。
由于错误而无法启动
# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
根据错误信息的建议,我查看了详细信息。
# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
└─http-proxy.conf
Active: failed (Result: start-limit) since 木 2023-05-11 16:14:48 JST; 5s ago
Docs: https://docs.docker.com
Process: 24696 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 24696 (code=exited, status=1/FAILURE)
5月 11 16:14:46 localhost.localdomain systemd[1]: Failed to start Docker Ap...
5月 11 16:14:46 localhost.localdomain systemd[1]: Unit docker.service enter...
5月 11 16:14:46 localhost.localdomain systemd[1]: docker.service failed.
5月 11 16:14:48 localhost.localdomain systemd[1]: docker.service holdoff ti...
5月 11 16:14:48 localhost.localdomain systemd[1]: Stopped Docker Applicatio...
5月 11 16:14:48 localhost.localdomain systemd[1]: start request repeated to...
5月 11 16:14:48 localhost.localdomain systemd[1]: Failed to start Docker Ap...
5月 11 16:14:48 localhost.localdomain systemd[1]: Unit docker.service enter...
5月 11 16:14:48 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
# journalctl -xeu docker.service
-- Unit docker.service has failed.
--
-- The result is failed.
5月 11 16:14:46 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
5月 11 16:14:46 localhost.localdomain systemd[1]: docker.service failed.
5月 11 16:14:48 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart.
5月 11 16:14:48 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine.
-- Subject: Unit docker.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has finished shutting down.
5月 11 16:14:48 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
5月 11 16:14:48 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
5月 11 16:14:48 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
5月 11 16:14:48 localhost.localdomain systemd[1]: docker.service failed.
嗯,不知道…
我试着附加调试选项启动。
# dockerd --debug
...
de997fc873 storage-driver=devicemapper
WARN[2023-05-11T16:37:19.507770761+09:00] Base device already exists and has filesystem xfs on it. User specified filesystem will be ignored. storage-driver=devicemapper
DEBU[2023-05-11T16:37:19.507790198+09:00] deactivateDevice START() storage-driver=devicemapper
DEBU[2023-05-11T16:37:19.507849410+09:00] devicemapper:RemoveDeviceDeferred START(docker-253:0-686081-base)
DEBU[2023-05-11T16:37:19.522229594+09:00] devicemapper: RemoveDeviceDeferred END(docker-253:0-686081-base)
DEBU[2023-05-11T16:37:19.522281442+09:00] deactivateDevice END() storage-driver=devicemapper
ERRO[2023-05-11T16:37:19.522380879+09:00] [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
...
ストレージドライバはdevicemapperが自動的に選択されたらしい。
devicemapperを使用するには明示的に指定しないといけないらしい。
参考: https://github.com/moby/moby/issues/22685 源代码提供了详细解释。
我查看了dockerd的启动选项。
打开/lib/systemd/system/docker.service文件,检查ExecStart行。
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
存储驱动程序未指定。
尝试通过指定存储驱动程序来启动Docker守护进程(Docker守护进程已成功运行)。
使用-s选项指定devicemapper。
ExecStart=/usr/bin/dockerd -s=devicemapper -H fd:// --containerd=/run/containerd/containerd.sock
启动
# sytemctl daemon-reload
# systemctl start docker
没有错误!Docker守护进程正在运行!
# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
└─http-proxy.conf
Active: active (running) since 木 2023-05-11 18:05:40 JST; 19h ago
我尝试运行了docker命令,但是。。。
# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
错误…似乎是连接方式不正确。
据说,Docker命令默认使用Unix套接字。
请参考以下链接来查看有关daemon-socket选项的详细信息:https://matsuand.github.io/docs.docker.jp.onthefly/engine/reference/commandline/dockerd/#daemon-socket-option
尝试设置Docker守护程序以在Unix套接字上进行监听并启动。
在命令行中使用-H选项指定unix:///var/run/docker.sock。
ExecStart=/usr/bin/dockerd -s=devicemapper -H unix:///var/run/docker.sock --containerd=/run/containerd/containerd.sock
重启并执行docker命令。
# systemctl daemon-reload
# systemctl restart docker
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
...
工作正常,没有出错!
最后
ExecStart=/usr/bin/dockerd -s=devicemapper -H unix:///var/run/docker.sock
を以下のように変更しました。
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
進行整理
ExecStart=/usr/bin/dockerd -s=devicemapper -H unix:///var/run/docker.sock --containerd=/run/containerd/containerd.sock
已经发生了变更。
我认为可能存在Linux内核更新导致的问题,或者更改存储驱动程序可能更好。如果有正确的解决方案或者任何错误之处,请您指点一下,我将不胜感激。
文献引用