Docker v23.0 启动报错 Job for docker. service failed because the control process exited with error code

背景介绍

最近最新版的 Kubernetes v1.27 发布了,打算重新装一套集群,结果在安装 Docker 的时候启动不起来了,报下面的错误:

Job for docker. service failed because the control process exited with error code

错误分析

网上的解决方案大同小异,都是修改 docker.service 文件或者是在 daemon.json 中增加代码的都试过了,都没有用。

现有的方法都试过了都没有用,那是不是版本的问题?

Docker 官网才发现 Docker 在最近的一段时间发布了 23.0 版本,直接从 v20v23 ,中间直接跳过两个大版本,具体原因也没说。

解决方案:

知道了原因就可以解决问题了,这里提供两种解决方案:回滚到 v20 低版本、修改 v23 配置文件。

回滚到 v20 低版本

先把系统上的最新的版本 Docker v23 卸载干净,然后重新安装 Docker v20

修改 v23 配置文件

如果不想降级,另一种解决方案就是修改配置文件。

Docker 配置文件 daemon.json/etc/docker/ 目录下,daemon.json 文件一般是自动生成或者是手动创建,但是在新版本 Docker v23 中,这个文件名改成 daemon.conf 了,具体是因为什么原因改动官方也没说。

解决方法也很简单,直接将 daemon.json 修改为 daemon.conf 即可,文件中配置内容完全一样。

修改文件名:

mv daemon.json daemon.conf

重启服务:

systemctl restart docker

推荐使用

推荐使用第一种方案,即回滚到 v20 低版本。

因为 Docker v23 会导致 kubernetes initerror execution phase couldn‘t initialize a Kubernetes cluster 的错误:

Unfortunately, an error has occurred:
	timed out waiting for the condition

This error is likely caused by:
	- The kubelet is not running
	- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
	- 'systemctl status kubelet'
	- 'journalctl -xeu kubelet'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.

Here is one example how you may list all Kubernetes containers running in docker:
	- 'docker ps -a | grep kube | grep -v pause'
	Once you have found the failing container, you can inspect its logs with:
	- 'docker logs CONTAINERID'

error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster	

原因没找到,据我猜测大概原因是因为 Docker 版本太新了,配置文件的后缀名改动影响了 Kubernetes

因为 Kubernetes1.24 之后就移除了 dockershim,所以安装最新版本的 Kubernetes 还想用 Docker 的话就需要安装 cri-dockerd,大概率是因为 cri-dockerd 读取的配置还是低版本的 daemon.json,而最新版本 Docker v23 的配置文件 daemon.conf 目前 cri-dockerd 还不支持。

猜你喜欢

转载自blog.csdn.net/yilovexing/article/details/130215372