转载说明:如果您喜欢这篇文章并打算转载它,请私信作者取得授权。感谢您喜爱本文,请文明转载,谢谢。
故事背景
前几天帮同事部署一个环境,用他写的安装脚本部署,其中一台服务器就需要安装docker,部署完了之后,发现docker启动失败了,/var/log/messages日志有如下提示:
Mar 29 09:41:47 Server-ad8c79fb-df4f-49f8-a28b-7c0dccdbccf5 dockerd: failed to start daemon: Error initializing network controller: error obtaining controller instance: invalid base pool "/16": invalid CIDR address: /16
Mar 29 09:41:47 Server-ad8c79fb-df4f-49f8-a28b-7c0dccdbccf5 systemd: docker.service: main process exited, code=exited, status=1/FAILURE
排查解决
根据failed to start daemon提示找到docker的damon.json文件,发现是在安装执行脚本过程中除了点小岔子,导致daemon.json文件的IP段不完整,最终导致了docker启动失败:
[root@test ~]# cat /etc/docker/daemon.json
{
"graph":"",
"exec-opts":["native.cgroupdriver=systemd"],
"insecure-registries": ["www.myharbor.com:9999"],
"registry-mirrors": ["https://1l3yp2sl.mirror.aliyuncs.com"],
"log-driver":"json-file",
"log-opts": {"max-size":"1024m", "max-file":"1"},
"default-address-pools": [
{
"base": "/16", #改成如10.0.0.0/16启动成功
"size": 24
}
],
"experimental": true,
"ip6tables": true
}
[root@test ~]#
将“base”字段缺失的IP补充齐全,再执行systemctl daemon-reload后,docker立即启动成功