1.先设置更新包
yum update -y
若不行,配置下源地址:
sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
软件-安装源地址
https://ftp.sjtu.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.ustc.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.njupt.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.163.com/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.huaweicloud.com/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.neusoft.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.cqu.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.bfsu.edu.cn/centos/8-stream/BaseOS/x86_64/os/
https://mirrors.nju.edu.cn/centos/8-stream/BaseOS/x86_64/os/
1.验证Linux内核,Docker 要求 CentOS 系统的内核版本高于 3.10
uname -r
2.更新yum
sudo yum update
3.安装yum需要的工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
4.设置yum源为阿里镜像
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5.安装Docker
CentOS8默认使用podman代替docker。直接安装docker会出现以下错误。
解决办法,命令后追加 –allowerasing
sudo yum install docker-ce docker-ce-cli containerd.io --allowerasing
或者先卸载podman,然后在安装docker
/** 下载podeman命令 **/
yum erase podman buildah/** 安装docker命令 **/
sudo yum install docker-ce docker-ce-cli containerd.io
安装指定版本的docker
/** 查看docker-ce-cli版本 **/
yum list docker-ce-cli --showduplicates|sort -r
/** 安装指定版本的docker **/
sudo yum install -y docker-ce-19.03.13 docker-ce-cli-19.03.13 containerd.io
5.启动并设置开机自启动
systemctl start docker
systemctl enable docker
6.测试是否成功
docker version