Centos离线安装Docker、Docker-compose、Harbor

离线安装Docker

  1. 配置 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
  2. 列出并排序在 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
    ......
    ......
    ......
  3. 下载指定版本的 docker-cedocker-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 为指定版本

  4. 复制下载的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%]
  5. 检查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
  6. 配置docker国内镜像

    csharp 复制代码
    [root@two docker24.0.4-offline-install]# vim /etc/docker/daemon.json
    
    {
        "registry-mirrors": ["https://ppc7nwnq.mirror.aliyuncs.com"]
    }
  7. 启动 Docker

    csharp 复制代码
    [root@two docker24.0.4-offline-install]# systemctl start docker
  8. 验证 Docker 是否启动成功

    csharp 复制代码
    [root@two docker24.0.4-offline-install]# docker ps
    CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
相关推荐
IT空门:门主24 分钟前
Spring 注入三剑客:@Resource、@Autowired、@RequiredArgsConstructor 到底该用哪个?
java·后端·spring
ServBay30 分钟前
云端 AI 蜜月期宣告结束,为什么 2026 年开发者转向本地优先架构
后端·ai编程
IT_陈寒35 分钟前
Vite这个坑我帮你踩了,动态导入居然这样才生效
前端·人工智能·后端
Sam_Deep_Thinking1 小时前
Spring Boot 的启动原理是什么?
java·spring boot·后端
南部余额1 小时前
Spring WebClient 从入门到精通
java·后端·spring
摇滚侠1 小时前
Spring 零基础入门到进阶 基于注解管理 Bean 38-43
xml·java·后端·spring·intellij-idea
SamDeepThinking1 小时前
我们当年是如何真实落地BFF的?
java·后端·架构
Asmewill1 小时前
Centos系统docker时间同步方案
后端
用户8356290780511 小时前
使用 Python 操作 Word 评论和回复
后端·python
心在飞扬2 小时前
CentOS + Node.js 全套部署命令
后端