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

相关推荐
吴声子夜歌1 小时前
Node.js——JSON-Server轻量级RESTful API
node.js·json·restful·json-server
杨浦老苏4 小时前
自托管网页EPUB阅读器Codexa
docker·群晖·电子书·calibre·opds
呆萌的代Ma4 小时前
解决n8n的输入内容报错JSON parameter needs to be valid JSON
json·n8n
杨浦老苏5 小时前
开源文件协作平台OpenCloud
docker·文件管理·群晖·协作
weixin_377634847 小时前
【MinerU】 Docker Compose 使用
docker·容器·mineru
庚昀◟8 小时前
腾讯云 CVM + Docker + Jenkins + GitLab CI/CD 全流程指南(python、flask实现简单计算器)
python·ci/cd·docker·flask·jenkins
PH = 78 小时前
K8S集群的搭建
云原生·容器·kubernetes
ErizJ8 小时前
Kubernetes|学习笔记
笔记·学习·kubernetes
SNOWPIAOP9 小时前
DOCKER的一些有用命令
docker
叶 落9 小时前
Ubuntu 通过 Docker 安装 Mysql8
linux·ubuntu·docker