
arbor 是由 VMware 开源的一款云原生制品仓库Harbor 的核心功能是存储和管理 Artifact。Harbor 允许用户用命令行工具对容器镜像及其他 Artifact 进行推送和拉取并提供了图形管理界面帮助用户查看和管理这些 Artifact。在 Harbor 2.0 版本中除容器镜像外Harbor 对符合 OCI 规范的 Helm Chart、CNAB、OPA Bundle 等都提供了更多的支持。Harbor 整体架构使用 Docker Compose 部署 Harbor硬件要求先安装 Docker Compose已有则忽略从 GitHub 下载最新版 Docker Compose 的二进制文件sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose赋予执行权限sudo chmod x /usr/local/bin/docker-compose验证安装docker-compose --version部署HarborHarbo下载Harbor的在线安装包wget https://github.com/goharbor/harbor/releases/download/v2.15.0/harbor-online-installer-v2.15.0.tgz tar -xzvf harbor-online-installer-v2.15.0.tgz创建并修改配置文件cd harbor cp harbor.yml.tmpl harbor.yml修改配置文件先注释HTTPS因为要做证书校验比较麻烦如果要https的 可以参照官$ vim harbor.yml hostname: 192.168.88.21 port: 5080 # 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 # enable strong ssl ciphers (default: false) # strong_ssl_ciphers: false文件修改完成后执行sudo ./install.sh出现如下错误需要配置Docker镜像代理执行成功根据在harbor.yml文件中配置的端口与IP地址进行访问http://:5080如http://192.168.88.21:5080默认管理员账号admin初始密码Harbor12345适用于v2.0及以上版本。 首次部署后需通过Web界面登录并强制修改密码。配置Mysql存储先在mysql数据库创建账号密码CREATE DATABASE harbor; CREATE USER harborlocahost IDENTIFIED BY harbor123; GRANT ALL PRIVILEGES ON harbor.* TO harbor_userlocahost ; FLUSH PRIVILEGES;再次更改harbor.yml配置文件database: type: mysql host: your_mysql_host port: 3306 username: harbor_user password: yourpassword database: harbor重新执行sudo ./install.sh设置自启sudo vim /etc/systemd/system/harbor.serviceHarbor放在 /etc/software/harbor/写入配置[Unit] DescriptionHarbor Registry Service Documentationhttps://goharbor.io Afterdocker.service network-online.target Requiresdocker.service Wantsnetwork-online.target [Service] Typeoneshot WorkingDirectory/etc/software/harbor ExecStart/usr/bin/docker compose up -d ExecStop/usr/bin/docker compose down RemainAfterExityes Restarton-failure RestartSec10 [Install] WantedBymulti-user.target启用并启动服务# 重载配置 sudo systemctl daemon-reload # 设置开机自启 sudo systemctl enable harbor # 立即启动服务 sudo systemctl start harbor # 查看状态 sudo systemctl status harbor