安装请参考:Install Docker Engine on CentOS | Docker Documentation
一:设置存储库
sudo yum install -y yum-utils
本人的是centos8的linux,由于centos8官方已经不在维护,出现这个错误
修改 /etc/yum.repos.d/CentOS-Linux-Extras.repo ,CentOS-Linux-BaseOS.repo,CentOS-Linux-AppStream.repo
CentOS-Linux-Extras.repo
baseurl=https://mirrors.aliyun.com/centos/$releasever-stream/extras/$basearch/os/
CentOS-Linux-BaseOS.repo
baseurl=https://mirrors.aliyun.com/centos/$releasever-stream/BaseOS/$basearch/os/
CentOS-Linux-AppStream.repo
baseurl=https://mirrors.aliyun.com/centos/$releasever-stream/AppStream/$basearch/os/
# 清除所有缓存文件
yum clean all
# 制作元数据缓存
yum makecache
到此处应该就能解决此问题,如果解决不了就百度解决。
然后继续进行:
sudo yum install -y yum-utils
设置存储库
//官方默认是国外镜像
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
设置阿里云镜像
sudo yum-config-manager \
--add-repo \
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
二:安装docker引擎
yum install docker-ce docker-ce-cli containerd.io
三:启动docker
systemctl start docker
使用docker version查看是否安装成功
docker version
四:测试hello-world
docker run hello-world
到此处则代表安装成功。
五:查看下载的hello-world镜像
docker images
六:卸载docker镜像
#卸载依赖
yum remove docker-ce docker-ce-cli containerd.io
#删除资源(默认的路径)
sudo rm -rf /var/lib/docker