1.安装docker依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
2.安装docker仓库
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
生成docker的yum源配置到在 /etc/yum.repos.d/docker-ce.repo
3.安装Docker Engine
yum install -y docker-ce docker-ce-cli containerd.io
出错了排查解决问题:
1.出错信息:
Requires: container-selinux >= 2:2.74
Requires: slirp4netns >= 0.4
Requires: fuse-overlayfs >= 0.7
2.解决:
2.1查看缺少依赖,执行 yum install slirp4netns fuse-overlayfs container-selinux也是不行。
2.2 到该地址https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/
查找对应的依赖包,使用rpm -ivh url 进行安装依赖
执行如下:
rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/slirp4netns-0.4.3-4.el7_8.x86_64.rpm
rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/fuse3-libs-3.6.1-4.el7.x86_64.rpm
rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/fuse3-devel-3.6.1-4.el7.x86_64.rpm
rpm -ivh https://mirrors.aliyun.com/centos/7.9.2009/extras/x86_64/Packages/fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
执行如下命令查看安装情况
rpm -qa container-selinux
rpm -qa slirp4netns
rpm -qa fuse-overlayfs
再次执行
yum install -y docker-ce docker-ce-cli containerd.io
docker安装成功。
4.配置docker镜像加速
百度搜索阿里云进入首页,在搜索框输入关键字“容器与镜像服务”
配置阿里的镜像加速还是不行(之前操作都是没问题的),感觉是失效了。
进行如下操作
vi /etc/docker/daemon.json 再加入如下地址
https://docker.m.daocloud.io
执行如下
sudo systemctl daemon-reload
sudo systemctl restart docker
再次操作可拉取到镜像hello-world并run起来了