DK-docker 离线安装

DK-docker 离线安装.png

重要表述

    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

你可能感兴趣的:(DK-docker 离线安装)