1、清理本地环境,卸载旧版本 卸载较旧的 Docker 版本称为 docker 或 docker-engine
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2、安装docker需要用到的yum工具类依赖
yum install yum-utils device-mapper-persistent-data lvm2 -y
3、添加docker仓库源地址(阿里云)
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4、安装docker(默认安装最新版本)
yum install docker-ce docker-ce-cli containerd.io -y
5、启动并设置自启动docker服务
systemctl enable docker —now
docker —version
6、镜像加速配置
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF’
{
"registry-mirrors": ["https://e5ptke54.mirror.aliyuncs.com”]
}
EOF
systemctl daemon-reload
systemctl restart docker