步骤如下:
1.卸载旧版本的docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engin
2.添加仓库文件和docker官方提供的服务器(或阿里云服务器)
yum install -y yum-utils
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo此步骤推荐:添加阿里云的:
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安装docker
yum install docker-ce docker-ce-cli containerd.io
4.启动docker
systemctl start docker
5.试运行
docker run hello-world
全过程:
[root@docker ~]# yum install -y yum-utils
[root@docker ~]# yum-config-manager \
> --add-repo\
> http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@docker ~]# yum install docker-ce docker-ce-cli containerd.io
[root@docker ~]# systemctl start docker
[root@docker ~]# docker run hello-world
试运行结果: