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所在行

  1. init 6 重启

重启OK

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值