问题复现
配置k8s的过程种,需要对docker进行换源,同时需要修改k8s的驱动方式,参考了其他博客,于是:
mkdir /etc/docker/
vim /etc/docker/daemon.json
在daemon.json写入:
{
"registry-mirrors" : ["https://mirror.aliyuncs.com"]
"exec-opts":["native.cgroupdriver=systemd"]
}
但是运行
systemctl restart docker
报错:
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
尝试解决
查了一些资料,建议:
1.卸载docker重装
2.删除掉daemon.json的空格
卸载docker重装
确实可以启动docker了,但是加入daemon.json之后仍然报错
删除掉daemon.json的空格
修改为
"registry-mirrors":["https://mirror.aliyuncs.com"]
仍然同样的报错
解决
发现是少了一个,
修改:
{
"registry-mirrors":["https://mirror.aliyuncs.com"],
"exec-opts":["native.cgroupdriver=systemd"]
}
成功!问题解决
[root@controller ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-05-07 14:17:32 CST; 1h 2min ago
Docs: https://docs.docker.com
Main PID: 21246 (dockerd)
Tasks: 30
Memory: 115.0M
CGroup: /system.slice/docker.service
└─21246 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
May 07 14:17:31 controller dockerd[21246]: time="2022-05-07T14:17:31.815404848+08:00" level=warning msg="Your kernel does not support cgroup blkio weight"
May 07 14:17:31 controller dockerd[21246]: time="2022-05-07T14:17:31.815446940+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
May 07 14:17:31 controller dockerd[21246]: time="2022-05-07T14:17:31.815670508+08:00" level=info msg="Loading containers: start."
May 07 14:17:32 controller dockerd[21246]: time="2022-05-07T14:17:32.372544226+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used t>
May 07 14:17:32 controller dockerd[21246]: time="2022-05-07T14:17:32.497479327+08:00" level=info msg="Loading containers: done."
May 07 14:17:32 controller dockerd[21246]: time="2022-05-07T14:17:32.577644629+08:00" level=info msg="Docker daemon" commit=4433bf6 graphdriver(s)=overlay2 version=20.10.15
May 07 14:17:32 controller dockerd[21246]: time="2022-05-07T14:17:32.577795711+08:00" level=info msg="Daemon has completed initialization"
May 07 14:17:32 controller systemd[1]: Started Docker Application Container Engine.