问题描述
CentOs7断电重启之后,使用systemctl start docker 命令重启docker服务,报错无法启动
1.首先猜测是有docker进程正在运行中,导致的冲突,查询docker相关进程
ps aux | grep docker
结果显示并没有docker的进程
2.根据提示信息查看具体的报错信息
怀疑是/usr/lib/systemd/system/docker.service文件有问题,查看此文件并与网上的进行对比,并没有发现问题,把该文件内容粘贴如下
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
Requires=docker.socket
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Older systemd versions default to a LimitNOFILE of 1024:1024, which is insufficient for many
# applications including dockerd itself and will be inherited. Raise the hard limit, while
# preserving the soft limit for select(2).
LimitNOFILE=1024:524288
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
3.查看docker是否完整无损坏docker version
发现正常
4.查看docker的服务是否存在
systemctl list-unit-files | grep docker
服务正常,未启动的状态
5.最后查看Linux的执行日值
tail -200f /var/log/messages
从日志中发现docker无法创建网桥,与自定义的网桥br0冲突,并且无法自动连接到自定义的网桥br0(自定义网桥参见在虚拟机上安装docker,在防火墙关闭的情况下,虚拟机可以联网,运行的容器内不能联网)
解决方法:
将/var/lib/docker/network/files目录下的文件全部删除.
local-kv.db文件记录了docker的网络信息,centos重启可能导致了该文件的损坏,导致网络连接出了问题。
启动docker,发现docker能正常运行
systemctl restart docker