部署采用的是阿里云的一键部署脚本:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
创建所需目录:
mkdir -p /etc/docker /data/docker
然后修改docker的配置文件:
/etc/docker/daemon.json { "graph": "/data/docker", "storage-driver": "overlay2", "insecure-registries": ["registry.access.redhat.com","quay.io","harbor.od.com"], "registry-mirrors": ["https://q2gr04ke.mirror.aliyuncs.com"], "bip": "172.7.21.1/24", "exec-opts": ["native.cgroupdriver=systemd"], "live-restore": true }
启动docker主进程:
systemctl start docker
报错如下:
-- Unit docker.service has begun starting up. 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.461032341+08:00" level=warning msg="The \"graph\" config file option is deprecated. Please use \"data- 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.461139245+08:00" level=info msg="Starting up" 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.462111770+08:00" level=info msg="parsed scheme: \"unix\"" module=grpc 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.462133686+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=gr 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.462156382+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/co 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.462170319+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.463849163+08:00" level=info msg="parsed scheme: \"unix\"" module=grpc 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.463873948+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=gr 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.463891615+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/co 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: time="2020-03-23T15:57:25.463901258+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc 3月 23 15:57:25 hdss7-200.host.com dockerd[4420]: failed to start daemon: error initializing graphdriver: overlay2: the backing <unknown> filesystem is formatted without d_type s 3月 23 15:57:25 hdss7-200.host.com systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
帖下环境的各个版本:
[root@hdss7-200 ~]# rpm -qa |grep docker docker-ce-cli-19.03.8-3.el7.x86_64 docker-ce-19.03.8-3.el7.x86_64 [root@hdss7-200 ~]# uname -a Linux hdss7-200.host.com 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@hdss7-200 ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
yum update -y 升级了系统也是无法重启
但是docker存储驱动我更换为devicemapper是可以启动的: "storage-driver": "devicemapper"
因为overlay2的性能是远高于devicemapper的,无论是生产环境还是docker的社区都是建议使用这个驱动,这个问题是绕不过的
百度了一下,我们下来看下文件系统是否支持了ftype,1表示开启,0为关闭
[root@hdss7-200 ~]# xfs_info /|grep ftype naming =version 2 bsize=4096 ascii-ci=0 ftype=0
由于我是mac的PD虚拟机虚拟出来的机器,windows使用VM可能不会遇到这个问题,ftype没有开启的话,重新格式化磁盘,加上这个参数的支持即可
我这里新加了一块磁盘,专门用来挂载docker的存储目录,打开虚机配置,新增磁盘
[root@test-docker ~]# fdisk -l 磁盘 /dev/sda:9663 MB, 9663676416 字节,18874368 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 4096 字节 I/O 大小(最小/最佳):4096 字节 / 4096 字节 磁盘标签类型:dos 磁盘标识符:0x00012036 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 1050623 524288 83 Linux /dev/sda2 1050624 2099199 524288 82 Linux swap / Solaris /dev/sda3 2099200 18868223 8384512 83 Linux 磁盘 /dev/sdb:4294 MB, 4294967296 字节,8388608 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 4096 字节 I/O 大小(最小/最佳):4096 字节 / 4096 字节
我们可以看到已经有了一块新的磁盘,接下来对磁盘格式化
[root@test-docker ~]# mkfs.xfs -n ftype=1 /dev/sdb meta-data=/dev/sdb isize=512 agcount=4, agsize=262144 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=1048576, 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=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
查看UUID,写入fstab挂载:
[root@test-docker ~]# blkid /dev/sdb /dev/sdb: UUID="19c3255a-1cfe-4636-b6fd-a3773b8c0dd4" TYPE="xfs" [root@test-docker ~]# cat /etc/fstab UUID=d267d18d-f3c2-4f41-9569-1e7b14c9bab9 / xfs defaults 0 0 UUID=b0c55bef-7339-4fe9-a3aa-a07a83b14796 /boot xfs defaults 0 0 UUID=cd27ca37-2d74-4276-b9bc-18e330da344d swap swap defaults 0 0 UUID=19c3255a-1cfe-4636-b6fd-a3773b8c0dd4 /data/docker xfs defaults 0 0 [root@test-docker ~]# mount -a
查看是否支持ftype:
[root@test-docker ~]# xfs_info /data/docker|grep ftype naming =version 2 bsize=4096 ascii-ci=0 ftype=1
再次启动docker进程,即可