添加yum源,并清空yum缓存
命令:
yum install epel-release -y
yum clean all
安装依赖项:
yum install -y yum-utils device-mapper-persistent-data lvm2
配置本地yum源:
yum-config-manager -y --add-repo https://download.docker.com/linux/centos/docker-ce.repo
或者:
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum -y install docker-ce
我这里运行出错了,是因为之前配置docker,有冲突(如果是新服务器,是不会出现这种情况的,自动忽略)。
Transaction check error:
file /usr/bin/docker from install of docker-ce-cli-1:26.1.1-1.el7.x86_64 conflicts with file from package docker-common-2:1.13.1-210.git7d71120.el7.centos.x86_64
file /usr/bin/dockerd from install of docker-ce-3:26.1.1-1.el7.x86_64 conflicts with file from package docker-common-2:1.13.1-210.git7d71120.el7.centos.x86_64
Error Summary
命令卸载即可:
yum erase docker docker-common-*
安装并且运行docker:
yum install -y docker-ce
出现这个界面,即完成安装。接下来按照需要自行配置喽。对啦,记得配置国内镜像源,不然下载镜像特别慢
需要的话,可以访问我另一篇文章。
配置docker镜像源