2.1.挂载数据盘
分区
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 1 of type Linux and of size 50 GiB is set
Command (m for help): w
The partition table has been altered!
格式化xfs文件系统
挂载测试
2.2.CentOS7使用Docker Overlay2存储驱动
Overlay2存储驱动需要4.0以上的kernel版本支持,须手动升级Kernel版本更高版本.CentOS7默认使用的文件系统是xfs,但xfs类型的文件系统参数d_type默认为false,需要重新格式化文件系统配置此参数.
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --enablerepo=elrepo-kernel install kernel-ml
a.查看系统上的所有可用内核
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
设置4.x kernel为默认启动,“0”为上面AWK命令的结果
grub2-set-default 0
c.生成grub配置文件并重启
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
d.挂载容器用的分区,并格式
fdisk /dev/sdc1
mkfs.xfs -n ftype=1 /dev/sdc1 -f
mount /dev/sdc1 /var/lib/docker
结果如下:
/dev/sdb1 xfs 54G 34M 54G 1% /var/discourse
/dev/sdc1 xfs 22G 34M 22G 1% /var/lib/docker
注:此处路径为 /var/lib/docker,路径错了折腾了快3小时了
安装稳定版本的docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum install docker-ce
增加配置
Edit /etc/docker/daemon.json
. If it does not yet exist, create it. Assuming that the file was empty, add the following contents.
{
"storage-driver": "overlay2"
}
修改docker镜象源,/etc/docker/daemon.json
增加如下配置
启动测试
systemctl enable docker
systemctl start docker
docker info
安装文档.参考官方:https://docs.docker.com/storage/storagedriver/overlayfs-driver/
https://www.jianshu.com/p/6e5da590aeda