当前位置: 代码迷 >> 综合 >> 【Docker】Docker 私有镜像仓库 Harbor 的安装
  详细解决方案

【Docker】Docker 私有镜像仓库 Harbor 的安装

热度:33   发布时间:2023-11-19 16:01:33.0

下载

下载地址:Harbor releases page,我下载的版本是 v2.0.2 离线安装版本
在这里插入图片描述

可以复制下载链接地址到迅雷上下载,直接下载比较慢

上传到服务器

在这里插入图片描述

安装

  • 解压

    tar -zxvf harbor-offline-installer-v2.0.2.tgz
    
  • 进入 harbor 目录修改配置文件

    cd harbor
    cp harbor.yml.tmpl harbor.yml
    vi harbor.yml
    
    # 第 5 行,修改主机名为自定义域名
    hostname: harbor.yuu.com# 第 12 行,注释掉 HTTPS 的相关配置
    # https related config
    # https:# https port for harbor, default is 443# port: 443# The path of cert and key files for nginx# certificate: /your/certificate/path# private_key: /your/private/key/path
    
  • 安装 Harbor

    ./install.sh# 输出如下
    [Step 0]: checking if docker is installed ...Note: docker version: 19.03.8[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.25.1[Step 2]: loading Harbor images ...
    cfc96945bc97: Loading layer [==================================================>]   34.5MB/34.5MB
    a518c7a82469: Loading layer [==================================================>]  77.32MB/77.32MB
    1f549f8baab9: Loading layer [==================================================>]   49.9MB/49.9MB
    947e25a6df39: Loading layer [==================================================>]   2.56kB/2.56kB
    0def86366021: Loading layer [==================================================>]  1.536kB/1.536kB
    2ee67f8195b4: Loading layer [==================================================>]  18.43kB/18.43kB
    69dc1c4a2254: Loading layer [==================================================>]  4.044MB/4.044MB
    7396cd67b3c8: Loading layer [==================================================>]  249.3kB/249.3kB
    Loaded image: goharbor/prepare:v2.0.2
    1d9f0912c4c0: Loading layer [==================================================>]  12.24MB/12.24MB
    03075e6cf76c: Loading layer [==================================================>]  3.584kB/3.584kB
    c29b9fe2d8ac: Loading layer [==================================================>]   2.56kB/2.56kB
    8b7737f50257: Loading layer [==================================================>]  59.64MB/59.64MB
    d82b643b50ec: Loading layer [==================================================>]  60.46MB/60.46MB
    Loaded image: goharbor/harbor-jobservice:v2.0.2
    de8b38b08d8a: Loading layer [==================================================>]  8.466MB/8.466MB
    3a1f4bd39ed3: Loading layer [==================================================>]  4.096kB/4.096kB
    bcb87c372187: Loading layer [==================================================>]  20.48MB/20.48MB
    e5bf53020920: Loading layer [==================================================>]  3.072kB/3.072kB
    03b969e21242: Loading layer [==================================================>]  8.721MB/8.721MB
    54dafa870c76: Loading layer [==================================================>]  30.02MB/30.02MB
    Loaded image: goharbor/harbor-registryctl:v2.0.2
    def1bb03a719: Loading layer [==================================================>]  8.466MB/8.466MB
    5e4e1cdaaece: Loading layer [==================================================>]  4.096kB/4.096kB
    4496530ea38e: Loading layer [==================================================>]  3.072kB/3.072kB
    cb7e7dcc7603: Loading layer [==================================================>]  20.48MB/20.48MB
    c3d295705a80: Loading layer [==================================================>]   21.3MB/21.3MB
    Loaded image: goharbor/registry-photon:v2.0.2
    20ad237979e7: Loading layer [==================================================>]  12.24MB/12.24MB
    8cf61da6095f: Loading layer [==================================================>]  3.584kB/3.584kB
    028ede4775e0: Loading layer [==================================================>]   2.56kB/2.56kB
    a5cd626cee36: Loading layer [==================================================>]  49.94MB/49.94MB
    4b78edfd1ecb: Loading layer [==================================================>]  5.632kB/5.632kB
    983f60904216: Loading layer [==================================================>]   51.2kB/51.2kB
    21e89cf5c88a: Loading layer [==================================================>]  50.77MB/50.77MB
    ebc05f2807cb: Loading layer [==================================================>]   2.56kB/2.56kB
    Loaded image: goharbor/harbor-core:v2.0.2
    e2a2cd60809d: Loading layer [==================================================>]   8.46MB/8.46MB
    7af97faea602: Loading layer [==================================================>]  6.317MB/6.317MB
    dd9e270f00b7: Loading layer [==================================================>]  14.43MB/14.43MB
    1c231ce43688: Loading layer [==================================================>]  27.96MB/27.96MB
    f3ce4a38e748: Loading layer [==================================================>]  22.02kB/22.02kB
    13c5030c8218: Loading layer [==================================================>]  48.71MB/48.71MB
    Loaded image: goharbor/notary-signer-photon:v2.0.2
    8e0c2e5ad650: Loading layer [==================================================>]  115.3MB/115.3MB
    d403e2ca2303: Loading layer [==================================================>]  12.12MB/12.12MB
    5416af7c643b: Loading layer [==================================================>]  3.072kB/3.072kB
    943416d990c1: Loading layer [==================================================>]  49.15kB/49.15kB
    e4dfc1abb4b2: Loading layer [==================================================>]  4.096kB/4.096kB
    b36748e9670d: Loading layer [==================================================>]  12.99MB/12.99MB
    Loaded image: goharbor/clair-photon:v2.0.2
    4ec0f25bdfa1: Loading layer [==================================================>]  9.762MB/9.762MB
    b9969c08c2da: Loading layer [==================================================>]  4.096kB/4.096kB
    6a7eb771560b: Loading layer [==================================================>]  3.072kB/3.072kB
    2c2e8ecbdfac: Loading layer [==================================================>]  23.44MB/23.44MB
    fe479ce0b9dc: Loading layer [==================================================>]  9.309MB/9.309MB
    d61f055843c6: Loading layer [==================================================>]  33.57MB/33.57MB
    Loaded image: goharbor/trivy-adapter-photon:v2.0.2
    15807e9ae4ac: Loading layer [==================================================>]  49.93MB/49.93MB
    6b66da1f7154: Loading layer [==================================================>]  3.584kB/3.584kB
    fe06369dd415: Loading layer [==================================================>]  3.072kB/3.072kB
    23d34fc061e9: Loading layer [==================================================>]   2.56kB/2.56kB
    bae3f85b39f0: Loading layer [==================================================>]  3.072kB/3.072kB
    8a6b565946fa: Loading layer [==================================================>]  3.584kB/3.584kB
    ac3b1ce278cf: Loading layer [==================================================>]  12.29kB/12.29kB
    c4a4ea69d0e1: Loading layer [==================================================>]  5.632kB/5.632kB
    Loaded image: goharbor/harbor-log:v2.0.2
    3878ef55fb9c: Loading layer [==================================================>]  10.31MB/10.31MB
    Loaded image: goharbor/nginx-photon:v2.0.2
    2e0a5c8816c3: Loading layer [==================================================>]  8.466MB/8.466MB
    6150d4d9a6b7: Loading layer [==================================================>]  4.096kB/4.096kB
    52524be7fa09: Loading layer [==================================================>]  3.072kB/3.072kB
    ba4d3fe7df7f: Loading layer [==================================================>]   9.71MB/9.71MB
    f331b9e56ece: Loading layer [==================================================>]  10.53MB/10.53MB
    Loaded image: goharbor/clair-adapter-photon:v2.0.2
    78a803768276: Loading layer [==================================================>]  8.465MB/8.465MB
    5ddbb1815a3a: Loading layer [==================================================>]  66.38MB/66.38MB
    bdbcf19e1816: Loading layer [==================================================>]  3.072kB/3.072kB
    34b4d5054926: Loading layer [==================================================>]  4.096kB/4.096kB
    e2d51a246850: Loading layer [==================================================>]  67.21MB/67.21MB
    Loaded image: goharbor/chartmuseum-photon:v2.0.2
    2b5d9ec67dd6: Loading layer [==================================================>]  10.31MB/10.31MB
    6053f98939e8: Loading layer [==================================================>]  8.488MB/8.488MB
    d04b1a887abc: Loading layer [==================================================>]  178.7kB/178.7kB
    2ca507515c90: Loading layer [==================================================>]  157.2kB/157.2kB
    6ff5df99ad6d: Loading layer [==================================================>]  33.28kB/33.28kB
    c6cf607726e4: Loading layer [==================================================>]  17.41kB/17.41kB
    bc304e71aedd: Loading layer [==================================================>]  15.36kB/15.36kB
    eae8aa3b596d: Loading layer [==================================================>]  3.584kB/3.584kB
    Loaded image: goharbor/harbor-portal:v2.0.2
    16c71bc320e5: Loading layer [==================================================>]   63.6MB/63.6MB
    30ebde76f438: Loading layer [==================================================>]  66.75MB/66.75MB
    f6df28e188ef: Loading layer [==================================================>]  6.144kB/6.144kB
    69d67866b922: Loading layer [==================================================>]   2.56kB/2.56kB
    8dae7135e814: Loading layer [==================================================>]   2.56kB/2.56kB
    d631bd06873a: Loading layer [==================================================>]   2.56kB/2.56kB
    09cbb5aba65b: Loading layer [==================================================>]   2.56kB/2.56kB
    83da103955f1: Loading layer [==================================================>]  11.26kB/11.26kB
    Loaded image: goharbor/harbor-db:v2.0.2
    9cbd9f1da31e: Loading layer [==================================================>]  39.48MB/39.48MB
    080b4be8f910: Loading layer [==================================================>]  3.072kB/3.072kB
    9bbc9af431df: Loading layer [==================================================>]   59.9kB/59.9kB
    d81804305687: Loading layer [==================================================>]  61.95kB/61.95kB
    Loaded image: goharbor/redis-photon:v2.0.2
    8302972bb01e: Loading layer [==================================================>]  15.84MB/15.84MB
    ca289d5344a0: Loading layer [==================================================>]  27.96MB/27.96MB
    bc763b1dd7a7: Loading layer [==================================================>]  22.02kB/22.02kB
    33e56bdcb04d: Loading layer [==================================================>]  50.11MB/50.11MB
    Loaded image: goharbor/notary-server-photon:v2.0.2[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...
    prepare base dir is set to /usr/local/docker/harbor
    WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
    Generated configuration file: /config/log/logrotate.conf
    Generated configuration file: /config/log/rsyslog_docker.conf
    Generated configuration file: /config/nginx/nginx.conf
    Generated configuration file: /config/core/env
    Generated configuration file: /config/core/app.conf
    Generated configuration file: /config/registry/config.yml
    Generated configuration file: /config/registryctl/env
    Generated configuration file: /config/registryctl/config.yml
    Generated configuration file: /config/db/env
    Generated configuration file: /config/jobservice/env
    Generated configuration file: /config/jobservice/config.yml
    Generated and saved secret to file: /data/secret/keys/secretkey
    Successfully called func: create_root_cert
    Generated configuration file: /compose_location/docker-compose.yml
    Clean up the input dir[Step 5]: starting Harbor ...
    Creating network "harbor_harbor" with the default driver
    Creating harbor-log ... done
    Creating registry      ... done
    Creating harbor-portal ... done
    Creating redis         ... done
    Creating registryctl   ... done
    Creating harbor-db     ... done
    Creating harbor-core   ... done
    Creating nginx             ... done
    Creating harbor-jobservice ... done
    ? ----Harbor has been installed and started successfully.----
    

    启动成功后访问 Harbor 服务器 80 端口,默认账号密码如下(可以在 harbor.yml 修改):

    • 账号:admin
    • 密码:Harbor12345

    在这里插入图片描述

    安装成功后会在 harbor 目录下自动生成 docker-compose.yml 配置文件,下一次可使用 Docker Compose 启动和停止

在 Docker 服务器配置镜像仓库

  • /etc/docker/daemon.json 中配置镜像仓库, 若没配置域名则使用 ip 即可
    {
          "insecure-registries": ["http://harbor.yuu.com"]
    }
    
  • 重启 Docker
    systemctl restart docker