
Harbor是一个开源的企业级 Docker 镜像仓库管理工具,由 VMware 公司(现为 Broadcom 旗下)创建并开源。它提供了镜像的存储、分发、安全和漏洞扫描等企业级功能,常用于 Kubernetes 和云原生环境中的镜像管理。
今天主要介绍其基本安装,安装过程较为简单,细节如下:
### 下载官方离线包
wget https://github.com/goharbor/harbor/releases/download/v2.1.3/harbor-offline-installer-v2.1.3.tgz
### 下载docker-compost
wget https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64
### 解压安装包并将目录放置于指定位置
tar xzvf harbor-offline-installer-v2.1.3.tgz
mv harbor /data
mv docker-compose-linux-x86_64 /usr/local/sbin/docker-compose
chmod +x /usr/local/sbin/docker-compose
### 创建日志与数据目录,修改配置文件
mkdir -p /data/harbor/{data,log}
cd /data/harbor
cp harbor.yml.tmpl harbor.yml
### 根据实际情况进行更改,hostname指定域名或IP,修改http port,注释掉https内容,更改harbor管理员及数据库密码,更改数据与日志存储位置。
vim harbor.yml
hostname: 192.168.40.15
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 8888
#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_admin_password: harbor管理员密码
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: 数据库密码
data_volume: /data/harbor/data
location: /data/harbor/log
### 安装harbor,安装完成后通过之前配置的地址及端口可以访问harbor web地址。
./install.sh --with-trivy --with-chartmuseum安装成功后通过管理员可以登录harbor web进行配置。按上面安装的地址来说,其web访问地址是
192.168.40.15:8888 用户名是admin 密码则是你配置文件中定义的 日常如果harbor异常或是出现假死等情况时,可以使用如下方式进行处理 ### harbor是由docker-compose维护,需要进入harbor安装目录执行命令 cd /data/harbor ### 查看harbor组件状态 docker-compose ps NAME COMMAND SERVICE STATUS PORTS chartmuseum "./docker-entrypoint…" chartmuseum running (healthy) harbor-core "/harbor/entrypoint.…" core running (healthy) harbor-db "/docker-entrypoint.…" postgresql running (healthy) harbor-jobservice "/harbor/entrypoint.…" jobservice running (healthy) harbor-log "/bin/sh -c /usr/loc…" log running (healthy) 127.0.0.1:1514->10514/tcp harbor-portal "nginx -g 'daemon of…" portal running (healthy) nginx "nginx -g 'daemon of…" proxy running (healthy) 0.0.0.0:8888->8080/tcp, :::8888->8080/tcp redis "redis-server /etc/r…" redis running (healthy) registry "/home/harbor/entryp…" registry running (healthy) registryctl "/home/harbor/start.…" registryctl running (healthy) trivy-adapter "/home/scanner/entry…" trivy-adapter running (healthy) ### 停止harbor docker-compose stop ### 启动harbor docker-compose start ### 重启harbor docker-compose restart