离线安装Docker
-
配置 CentOS 系统的 Docker 安装源为清华大学的镜像源
shell#下载清华的镜像源文件 wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo yum update
-
列出并排序在 yum 仓库中所有可用的
docker-ce
版本shell[root@three harbor2.7.4]# sudo yum list docker-ce --showduplicates|sort -r * updates: mirrors.aliyun.com Loading mirror speeds from cached hostfile Loaded plugins: fastestmirror Installed Packages * extras: mirrors.aliyun.com docker-ce.x86_64 3:24.0.7-1.el7 docker-ce-stable docker-ce.x86_64 3:24.0.6-1.el7 docker-ce-stable docker-ce.x86_64 3:24.0.5-1.el7 docker-ce-stable docker-ce.x86_64 3:24.0.4-1.el7 installed docker-ce.x86_64 3:24.0.4-1.el7 docker-ce-stable ...... ...... ......
-
下载指定版本的
docker-ce
和docker-ce-cli
安装包yaml[root@two docker24.0.4-offline-install]# sudo yum install --downloadonly --downloaddir=/opt/software/docker24.0.4-offline-install docker-ce-24.0.4-1.el7 docker-ce-cli-24.0.4-1.el7 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.163.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 Resolving Dependencies ...... ......
/opt/software/docker24.0.4-offline-install
为下载路径
24.0.4-1.el7
为指定版本 -
复制下载的docker安装包到目标服务器,进入目录后执行
ruby[root@two docker24.0.4-offline-install]# rpm -Uvh *.rpm --nodeps --force Preparing... ################################# [100%] Updating / installing... 1:docker-compose-plugin-0:2.21.0-1.################################# [ 17%] 2:docker-buildx-plugin-0:0.11.2-1.e################################# [ 33%] 3:docker-ce-cli-1:24.0.4-1.el7 ################################# [ 50%] 4:containerd.io-1.6.25-3.1.el7 ################################# [ 67%] 5:docker-ce-rootless-extras-0:24.0.################################# [ 83%] 6:docker-ce-3:24.0.4-1.el7 ################################# [100%]
-
检查docker是否安装成功
ini[root@two docker24.0.4-offline-install]# yum list installed | grep docker docker-buildx-plugin.x86_64 0.11.2-1.el7 installed docker-ce.x86_64 3:24.0.4-1.el7 installed docker-ce-cli.x86_64 1:24.0.4-1.el7 installed docker-ce-rootless-extras.x86_64 24.0.7-1.el7 installed docker-compose-plugin.x86_64 2.21.0-1.el7 installed
-
配置docker国内镜像
csharp[root@two docker24.0.4-offline-install]# vim /etc/docker/daemon.json { "registry-mirrors": ["https://ppc7nwnq.mirror.aliyuncs.com"] }
-
启动 Docker
csharp[root@two docker24.0.4-offline-install]# systemctl start docker
-
验证 Docker 是否启动成功
csharp[root@two docker24.0.4-offline-install]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES