安装Docker服务
1、使用 root 权限更新 yum 包 :yum -y update
2、安装需要的软件包:yum install -y yum-utils device-mapper-persistent-data lvm2

3、设置 yum 源:yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

4、卸载旧版本
yum remove docker docker-common docker-selinux docker-engine

5、查看docker可用版本:yum list docker-ce --showduplicates | sort -r
6、选择最新或者指定版本:yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

7、启动 Docker 并设置开机自启:systemctl start docker
systemctl enable docker

相关问题
systemctl start network命令重启网卡失败,将命令改为systemctl restart NetworkManager

Failed to set locale, defaulting to C.UTF-8
echo "export LC_ALL=en_US.utf8" >> /etc/profile
source /etc/profile

解决镜像源的问题
源文件备份
cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/
下载源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
更新源地址
sed -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*
sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*
生成缓存
yum clean all && yum makecache

安装Docker出现和Podman冲突:
yum erase podman buildah

网友评论