1、移除以前docker相关包

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2、配置yum源

sudo yum install -y yum-utils

sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3、安装小工具

yum install -y net-tools.x86_64 vim wget crul unzip

4、安装docker

yum install -y docker-ce docker-ce-cli containerd.io

#安装特定版本,安装配套k8s时用这个
yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7  containerd.io-1.4.6

5、启动docker并设置开机自启

systemctl enable docker --now

6、配置加速

sudo vim /etc/docker/daemon.json

6.1、设置镜像加速和日志分包

{
    "registry-mirrors": [
        "https://qiojqnqv.mirror.aliyuncs.com",
    	"https://hub-mirror.c.163.com",
    	"https://mirror.baidubce.com"
      ],
    "log-driver": "json-file",
    "log-opts": {
        "max-size":"100m", 
        "max-file":"3"
    }
}

6.2、重启docker服务

sudo systemctl daemon-reload