1、相关版本信息: 操作系统版本和docker版本如下:
[root@localhost_02 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost_02 ~]# rpm -qa|grep docker
docker-ce-cli-18.09.4-3.el7.x86_64
docker-ce-18.09.4-3.el7.x86_64
2、下载docker 镜像:并通过yum安装:
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker.repo
yum makecache fast
yum isntall -y docker-ce
3、启动时报错: systemctl start docker
[root@localhost_02 ~]# systemctl start docker
Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details.
4、通过 systemctl status docker.service 查看,发现并没有什么错误信息
也可以通过 dockerd 来查看错误信息
5、那么只好去查看系统日记里: tail -n300 /var/log/message
Apr 4 22:09:05 localhost_02 dockerd: time="2019-04-04T22:09:05.923374456+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Apr 4 22:09:05 localhost_02 dockerd: time="2019-04-04T22:09:05.923397271+08:00" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc420612b60, CONNECTING" module=grpc
Apr 4 22:09:05 localhost_02 dockerd: time="2019-04-04T22:09:05.923650712+08:00" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0xc420612b60, READY" module=grpc
Apr 4 22:09:05 localhost_02 dockerd: time="2019-04-04T22:09:05.935611728+08:00" level=warning msg="Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man dockerd` to refer to dm.thinpooldev section." storage-driver=devicemapper
Apr 4 22:09:06 localhost_02 kernel: bio: create slab <bio-2> at 2
Apr 4 22:09:06 localhost_02 dockerd: time="2019-04-04T22:09:06.128742412+08:00" level=info msg="Creating filesystem xfs on device docker-8:3-67789151-base, mkfs args: [-m crc=0,finobt=0 /dev/mapper/docker-8:3-67789151-base]" storage-driver=devicemapper
Apr 4 22:09:06 localhost_02 dockerd: time="2019-04-04T22:09:06.131080987+08:00" level=info msg="Error while creating filesystem xfs on device docker-8:3-67789151-base: exit status 1" storage-driver=devicemapper
Apr 4 22:09:06 localhost_02 dockerd: time="2019-04-04T22:09:06.131103910+08:00" level=error msg="[graphdriver] prior storage driver devicemapper failed: exit status 1"
Apr 4 22:09:08 localhost_02 dockerd: time="2019-04-04T22:09:08.621022391+08:00" level=info msg="Creating filesystem xfs on device docker-8:3-67789151-base, mkfs args: [-m crc=0,finobt=0 /dev/mapper/docker-8:3-67789151-base]" storage-driver=devicemapper
Apr 4 22:09:08 localhost_02 dockerd: time="2019-04-04T22:09:08.622238270+08:00" level=info msg="Error while creating filesystem xfs on device docker-8:3-67789151-base: exit status 1" storage-driver=devicemapper
Apr 4 22:09:08 localhost_02 dockerd: time="2019-04-04T22:09:08.622258464+08:00" level=error msg="[graphdriver] prior storage driver devicemapper failed: exit status 1"
注释:上面 error 标红的字体:注意到 mkfs ,然后手动执行下;
[root@localhost_02 ~]# mkfs.xfs -m crc=0,finobt=0 /dev/mapper/docker-8:3-67789151-base
unknown option -m finobt=0
Usage: mkfs
提示 -m 参数不存在; man mkfs.xfs 发现没有 -m 参数;
可能是版本太低的原因: yum update xfsprogs
然后再次执行:mkfs.xfs -m crc=0,finobt=0 /dev/mapper/docker-8:3-67789151-base
[root@localhost_02 ~]# mkfs.xfs -m crc=0,finobt=0 /dev/mapper/docker-8:3-67789151-base
meta-data=/dev/mapper/docker-8:3-67789151-base isize=256 agcount=4, agsize=655360 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0, sparse=0
data = bsize=4096 blocks=2621440, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
5、再次启动:发现启动成功了;
[root@localhost_02 ~]# systemctl start docker.service
[root@localhost_02 ~]# ps aux |grep docker
root 4179 3.6 3.5 529704 55308 ? Ssl 22:14 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 4318 0.0 0.0 112656 988 pts/0 R+ 22:14 0:00 grep --color=auto docker