k8s、docker添加daemon.json添加“exec-opts“: [“native.cgroupdriver=systemd“]后无法启动的问题

考虑k8s下docker下载镜像太慢,修改了daemon.json,按照手册抄,添加

复制代码
{
	"exec-opts": ["native.cgroupdriver=systemd"],
	"registry-mirrors": ["https://kn0t2bca.mirror.aliyuncs.com"]
}

结果发现k8s起不来了,

-- Unit docker.service has begun starting up.

Aug 10 22:02:01 k8s-master dockerd[1831]: unable to configure the Docker daemon with file /etc/docker/daemon.json : the following directives are specified both as a flag and in the configuration file: exec-opts : (from flag: [native.cgroupdriver=systemd] , from file: [native.cgroupdriver=systemd] )

Aug 10 22:02:01 k8s-master systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE

Aug 10 22:02:01 k8s-master 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.

Aug 10 22:02:01 k8s-master systemd[1]: Unit docker.service entered failed state.

Aug 10 22:02:01 k8s-master systemd[1]: docker.service failed.

原因

启动失败原因:直接启动docker会报错,因为docker.service里有一条配置,和刚才添加的"exec-opts"冲突了

复制代码
# /lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd

解决方案,保留一处正确的即可:

1.1. # docker.service 找到并删除下面这句话,保存退出,即可解决
--exec-opt native.cgroupdriver=cgroupfs \

1.2. # 或者daemon.json

删exec-opt所在行

init 6 重启

重启OK

相关推荐
70asunflower18 分钟前
Emulation,Simulation,Virtualization,Imitation 的区别?
linux·docker
ShiLiu_mtx1 小时前
k8s - 7
云原生·容器·kubernetes
春日见1 小时前
车辆动力学:前后轮车轴
java·开发语言·驱动开发·docker·计算机外设
xuhe21 小时前
[全流程详细教程]Docker部署ClawBot, 使用GLM4.7, 接入TG Bot实现私人助理. 解决Docker Openclaw Permission Denied问题
linux·docker·ai·github·tldr
星火s漫天2 小时前
第一篇: 使用Docker部署flask项目(Flask + DB 容器化)
数据库·docker·flask
MonkeyKing_sunyuhua4 小时前
docker compose up -d --build 完全使用新代码打包的方法
docker·容器·eureka
醇氧4 小时前
【docker】mysql 8 的健康检查(Health Check)
mysql·docker·容器
技术路上的探险家5 小时前
Ubuntu下Docker与NVIDIA Container Toolkit完整安装教程(含国内源适配)
linux·ubuntu·docker
CSCN新手听安7 小时前
【linux】网络基础(三)TCP服务端网络版本计算器的优化,Json的使用,服务器守护进程化daemon,重谈OSI七层模型
linux·服务器·网络·c++·tcp/ip·json
bloglin999998 小时前
Qwen3-32B报错Invalid json output:{“type“: “1“}For troubleshooting, visit
llm·json