重要表述
Hi,我是 DK。
在通过我:” 2 * 8 = 24 ? “ 天的 ” 刿心刳肺、衡虑困心、殚精竭虑、搜索枯肠、殚精竭虑、裁心镂舌 ”,终于总结出了这 ” 超群绝伦 ” 的文章。最初我得出了一个强有力的僻邪剑谱:” 那人长得吧,怎么说呢。像素比拟低!”。
该吹的牛也吹完了咱们开始明天的正题,docker 编译离线吧。
测试环境
# 零碎: CentOS 7
# 版本:3.10.0-1160.el7.x86_64
执行流程
# setp 1: 如果之前曾经装置过则须要删除,若没有则跳过。# 查看是否装置过 docker
sudo rpm -qa | grep docker
#[root@localhost ~]# rpm -qa | grep docker
#docker-ce-cli-20.10.18-3.el7.x86_64
#docker-ce-rootless-extras-20.10.18-3.el7.x86_64
#docker-scan-plugin-0.17.0-3.el7.x86_64
#docker-ce-20.10.18-3.el7.x86_64
# 卸载 Docker
# 形式一: yum 卸载
# 针对 yum 装置的 docker
yum remove docker-ce docker-ce-cli containerd.io
# 删除 docker 相干文件
rm -rf /etc/docker
rm -rf /run/docker
rm -rf /var/lib/docker
rm -rf /usr/libexec/docker
# 形式二: 手动卸载
# 杀死所有运行容器
docker kill `docker ps -a -q`
# 删除所有容器
docker rm `docker ps -a -q`
# 删除所有镜像
docker rmi `docker images -q`
# 进行 docker 服务
systemctl stop docker
# 卸载所以 docker -*
rpm -e `rpm -qa | grep docker`
# step 2: 下载离线的安装包,都下载最新的且架构为 x86_64
# https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
# http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
# 需下载的包如下:containerd.io-1.6.8-3.1.el7.x86_64.rpm
container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
docker-ce-20.10.9-3.el7.x86_64.rpm
docker-ce-cli-20.10.9-3.el7.x86_64.rpm
docker-ce-rootless-extras-20.10.9-3.el7.x86_64.rpm
docker-scan-plugin-0.9.0-3.el7.x86_64.rpm
# step 3: 装置 docker
rpm -ivh container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
rpm -ivh containerd.io-1.6.8-3.1.el7.x86_64.rpm
rpm -ivh docker-scan-plugin-0.9.0-3.el7.x86_64.rpm
rpm -ivh docker-ce-cli-20.10.9-3.el7.x86_64.rpm
rpm -ivh docker-ce-cli-20.10.9-3.el7.x86_64.rpm
rpm -ivh docker-ce-20.10.9-3.el7.x86_64.rpm
# setp 4: 启动服务
sudo systemctl start docker
# setp 5: 验证是否胜利, 后果如下则阐明装置胜利
# - 查看 docker 版本
docker -v
#[root@localhost ~]# docker -v
#Docker version 20.10.18, build b40c2f6
# - 下拉镜像
docker pull redis
# - 查看镜像
docker images
#[root@localhost ~]# docker images
#REPOSITORY TAG IMAGE ID CREATED SIZE
#redis latest dc7b40a0b05d 2 weeks ago 117MB
# - 运行镜像
docker run --name redis -d redis
# - 进入容器并进行测试
docker exec -it redis bash
#[root@localhost ~]# docker exec -it redis bash
#root@4d0f49919bf7:/data# redis-cli
#127.0.0.1:6379> ping
#PONG
报错解决
# (1) 装置报错, 强制装置
#[root@localhost ~]# rpm -ivh containerd.io-1.6.8-3.1.el7.x86_64.rpm
#error: Failed dependencies:
# containerd conflicts with containerd.io-1.6.8-3.1.el7.x86_64
# runc conflicts with containerd.io-1.6.8-3.1.el7.x86_64
# containerd conflicts with (installed) containerd.io-1.6.8-3.1.el7.x86_64
# runc conflicts with (installed) containerd.io-1.6.8-3.1.el7.x86_64
rpm -ivh containerd.io-1.6.8-3.1.el7.x86_64.rpm --nodeps
# (2) 装置报错, 强制装置
#[root@localhost ~]# rpm -ivh docker-scan-plugin-0.9.0-3.el7.x86_64.rpm
#error: Failed dependencies:
# docker-ce-cli is needed by docker-scan-plugin-0:0.9.0-3.el7.x86_64
rpm -ivh docker-scan-plugin-0.9.0-3.el7.x86_64.rpm --nodeps
# (3) 装置报错, 强制装置
#[root@localhost ~]# rpm -ivh docker-ce-rootless-extras-20.10.9-3.el7.x86_64.rpm
#error: Failed dependencies:
# docker-ce is needed by docker-ce-rootless-extras-0:20.10.9-3.el7.x86_64
rpm -ivh docker-ce-rootless-extras-20.10.9-3.el7.x86_64.rpm --nodeps