1 环境
2 docker 与 docker-compose
bruce@bruce-VirtualBox:~/harbor$ docker -v & docker-compose -v
[1] 36159
Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2
docker-compose version 1.25.0, build unknown
[1]+ 已完成 docker -v
bruce@bruce-VirtualBox:~/harbor$
题外话,开始没有 docker-compose,直接执行 sudo apt install docker-compose
3 安装
3.1 离线下载
下载地址:https://github.com/goharbor/harbor/releases 选择自己的版本,本次使用的是 2.4.2
3.2 解压
解压: tar -zxvf harbor-offline-installer-v2.4.2.tgz
3.3 配置
配置:cp harbor.yml.tmp harbor.yml,并修改 harbor.yml
主要是hostname,密码,https,docker volume 等
下面是全部的 harbor.yml 内容:
# Configuration file of Harbor
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 10.0.2.4
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# 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
# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
# # set enabled to true means internal tls is enabled
# enabled: true
# # put your cert and key files on dir
# dir: /etc/harbor/tls/internal
# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433
# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345
# Harbor DB configuration
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 100
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 1024 for postgres of harbor.
max_open_conns: 900
# The default data volume
data_volume: /data
# Harbor Storage settings by default is using /data dir on local filesystem
# Uncomment storage_service setting If you want to using external storage
# storage_service:
# # ca_bundle is the path to the custom root ca certificate, which will be injected into the truststore
# # of registry's and chart repository's containers. This is usually needed when the user hosts a internal storage with self signed certificate.
# ca_bundle:
# # storage backend, default is filesystem, options include filesystem, azure, gcs, s3, swift and oss
# # for more info about this configuration please refer https://docs.docker.com/registry/configuration/
# filesystem:
# maxthreads: 100
# # set disable to true when you want to disable registry redirect
# redirect:
# disabled: false
# Trivy configuration
#
# Trivy DB contains vulnerability information from NVD, Red Hat, and many other upstream vulnerability databases.
# It is downloaded by Trivy from the GitHub release page https://github.com/aquasecurity/trivy-db/releases and cached
# in the local file system. In addition, the database contains the update timestamp so Trivy can detect whether it
# should download a newer version from the Internet or use the cached one. Currently, the database is updated every
# 12 hours and published as a new release to GitHub.
trivy:
# ignoreUnfixed The flag to display only fixed vulnerabilities
ignore_unfixed: false
# skipUpdate The flag to enable or disable Trivy DB downloads from GitHub
#
# You might want to enable this flag in test or CI/CD environments to avoid GitHub rate limiting issues.
# If the flag is enabled you have to download the `trivy-offline.tar.gz` archive manually, extract `trivy.db` and
# `metadata.json` files and mount them in the `/home/scanner/.cache/trivy/db` path.
skip_update: false
#
# The offline_scan option prevents Trivy from sending API requests to identify dependencies.
# Scanning JAR files and pom.xml may require Internet access for better detection, but this option tries to avoid it.
# For example, the offline mode will not try to resolve transitive dependencies in pom.xml when the dependency doesn't
# exist in the local repositories. It means a number of detected vulnerabilities might be fewer in offline mode.
# It would work if all the dependencies are in local.
# This option doesn’t affect DB download. You need to specify "skip-update" as well as "offline-scan" in an air-gapped environment.
offline_scan: false
#
# insecure The flag to skip verifying registry certificate
insecure: false
# github_token The GitHub access token to download Trivy DB
#
# Anonymous downloads from GitHub are subject to the limit of 60 requests per hour. Normally such rate limit is enough
# for production operations. If, for any reason, it's not enough, you could increase the rate limit to 5000
# requests per hour by specifying the GitHub access token. For more details on GitHub rate limiting please consult
# https://developer.github.com/v3/#rate-limiting
#
# You can create a GitHub token by following the instructions in
# https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
#
# github_token: xxx
jobservice:
# Maximum number of job workers in job service
max_job_workers: 10
notification:
# Maximum retry count for webhook job
webhook_job_max_retry: 10
chart:
# Change the value of absolute_url to enabled can enable absolute url in chart
absolute_url: disabled
# Log configurations
log:
# options are debug, info, warning, error, fatal
level: info
# configs for logs in local storage
local:
# Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
rotate_count: 50
# Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes.
# If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G
# are all valid.
rotate_size: 200M
# The directory on your host that store log
location: /var/log/harbor
# Uncomment following lines to enable external syslog endpoint.
# external_endpoint:
# # protocol used to transmit log to external endpoint, options is tcp or udp
# protocol: tcp
# # The host of external endpoint
# host: localhost
# # Port of external endpoint
# port: 5140
#This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
_version: 2.4.0
# Uncomment external_database if using external database.
# external_database:
# harbor:
# host: harbor_db_host
# port: harbor_db_port
# db_name: harbor_db_name
# username: harbor_db_username
# password: harbor_db_password
# ssl_mode: disable
# max_idle_conns: 2
# max_open_conns: 0
# notary_signer:
# host: notary_signer_db_host
# port: notary_signer_db_port
# db_name: notary_signer_db_name
# username: notary_signer_db_username
# password: notary_signer_db_password
# ssl_mode: disable
# notary_server:
# host: notary_server_db_host
# port: notary_server_db_port
# db_name: notary_server_db_name
# username: notary_server_db_username
# password: notary_server_db_password
# ssl_mode: disable
# Uncomment external_redis if using external Redis server
# external_redis:
# # support redis, redis+sentinel
# # host for redis: <host_redis>:<port_redis>
# # host for redis+sentinel:
# # <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3>
# host: redis:6379
# password:
# # sentinel_master_set must be set to support redis+sentinel
# #sentinel_master_set:
# # db_index 0 is for core, it's unchangeable
# registry_db_index: 1
# jobservice_db_index: 2
# chartmuseum_db_index: 3
# trivy_db_index: 5
# idle_timeout_seconds: 30
# Uncomment uaa for trusting the certificate of uaa instance that is hosted via self-signed cert.
# uaa:
# ca_file: /path/to/ca
# Global proxy
# Config http proxy for components, e.g. http://my.proxy.com:3128
# Components doesn't need to connect to each others via http proxy.
# Remove component from `components` array if want disable proxy
# for it. If you want use proxy for replication, MUST enable proxy
# for core and jobservice, and set `http_proxy` and `https_proxy`.
# Add domain to the `no_proxy` field, when you want disable proxy
# for some special registry.
proxy:
http_proxy:
https_proxy:
no_proxy:
components:
- core
- jobservice
- trivy
# metric:
# enabled: false
# port: 9090
# path: /metrics
# Trace related config
# only can enable one trace provider(jaeger or otel) at the same time,
# and when using jaeger as provider, can only enable it with agent mode or collector mode.
# if using jaeger collector mode, uncomment endpoint and uncomment username, password if needed
# if using jaeger agetn mode uncomment agent_host and agent_port
# trace:
# enabled: true
# # set sample_rate to 1 if you wanna sampling 100% of trace data; set 0.5 if you wanna sampling 50% of trace data, and so forth
# sample_rate: 1
# # # namespace used to differenciate different harbor services
# # namespace:
# # # attributes is a key value dict contains user defined attributes used to initialize trace provider
# # attributes:
# # application: harbor
# # # jaeger should be 1.26 or newer.
# # jaeger:
# # endpoint: http://hostname:14268/api/traces
# # username:
# # password:
# # agent_host: hostname
# # # export trace data by jaeger.thrift in compact mode
# # agent_port: 6831
# # otel:
# # endpoint: hostname:4318
# # url_path: /v1/traces
# # compression: false
# # insecure: true
# # timeout: 10s
3.4 prepare 预处理
预处理一下:sudo ./prepare 会生成相关的配置等
bruce@bruce-VirtualBox:~/harbor$ sudo ./prepare
[sudo] bruce 的密码:
prepare base dir is set to /home/bruce/harbor
Unable to find image 'goharbor/prepare:v2.4.2' locally
v2.4.2: Pulling from goharbor/prepare
6c964f3b879f: Pull complete
3042f4284e2c: Pull complete
7a91ea24644b: Pull complete
b3c79e094a18: Pull complete
110443f7949d: Pull complete
1fbee02500d7: Pull complete
8675c3a61fe1: Pull complete
d48514bf9c2b: Pull complete
Digest: sha256:b14da6252672c596291f02a5e76fbb065f558aaf0a647f90e1c77aefaa29db74
Status: Downloaded newer image for goharbor/prepare:v2.4.2
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/portal/nginx.conf
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
bruce@bruce-VirtualBox:~/harbor$
3.5 安装
安装:sudo ./install.sh
bruce@bruce-VirtualBox:~/harbor$ sudo ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.7
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 1.25.0
[Step 2]: loading Harbor images ...
7abced50bfd2: Loading layer [==================================================>] 5.296MB/5.296MB
43ad630c07b8: Loading layer [==================================================>] 5.928MB/5.928MB
3457e72d7725: Loading layer [==================================================>] 14.47MB/14.47MB
4a079b4b377a: Loading layer [==================================================>] 29.29MB/29.29MB
7b180b7bf3b4: Loading layer [==================================================>] 22.02kB/22.02kB
7b678649a1be: Loading layer [==================================================>] 14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.4.2
4f650960b0dc: Loading layer [==================================================>] 5.832MB/5.832MB
967788659fd5: Loading layer [==================================================>] 4.096kB/4.096kB
30cc19bdf2d6: Loading layer [==================================================>] 3.072kB/3.072kB
9ccede1a4324: Loading layer [==================================================>] 47.85MB/47.85MB
86f4685faff0: Loading layer [==================================================>] 12.38MB/12.38MB
25af1cf9c44e: Loading layer [==================================================>] 61.02MB/61.02MB
Loaded image: goharbor/trivy-adapter-photon:v2.4.2
Loaded image: goharbor/prepare:v2.4.2
323ed00cae7e: Loading layer [==================================================>] 8.447MB/8.447MB
c3f8c4668352: Loading layer [==================================================>] 3.584kB/3.584kB
94b71cd07106: Loading layer [==================================================>] 2.56kB/2.56kB
5d5638decfe4: Loading layer [==================================================>] 75.6MB/75.6MB
48426521f41c: Loading layer [==================================================>] 5.632kB/5.632kB
bb977315930e: Loading layer [==================================================>] 97.28kB/97.28kB
2a80a5f64ee7: Loading layer [==================================================>] 11.78kB/11.78kB
0a5146355ed0: Loading layer [==================================================>] 76.5MB/76.5MB
7d5eac57d5fa: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.4.2
f7cedf07c50c: Loading layer [==================================================>] 8.447MB/8.447MB
b2a916599ac7: Loading layer [==================================================>] 3.584kB/3.584kB
3bc2556f46f8: Loading layer [==================================================>] 2.56kB/2.56kB
a9cc192089ec: Loading layer [==================================================>] 86.96MB/86.96MB
9e9c53c1bd85: Loading layer [==================================================>] 87.75MB/87.75MB
Loaded image: goharbor/harbor-jobservice:v2.4.2
6111e09009c2: Loading layer [==================================================>] 7.222MB/7.222MB
Loaded image: goharbor/nginx-photon:v2.4.2
f4658d2c3aa3: Loading layer [==================================================>] 8.447MB/8.447MB
4b7bdcad271f: Loading layer [==================================================>] 18.13MB/18.13MB
cbb8c130a490: Loading layer [==================================================>] 4.608kB/4.608kB
f1367013643c: Loading layer [==================================================>] 18.93MB/18.93MB
Loaded image: goharbor/harbor-exporter:v2.4.2
a1b12e0ab8ea: Loading layer [==================================================>] 5.296MB/5.296MB
df6629a5ee28: Loading layer [==================================================>] 5.928MB/5.928MB
944fcde3a84b: Loading layer [==================================================>] 15.88MB/15.88MB
300e181c27cf: Loading layer [==================================================>] 29.29MB/29.29MB
87f01e78dde1: Loading layer [==================================================>] 22.02kB/22.02kB
8306283aa89d: Loading layer [==================================================>] 15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.4.2
c635aace513a: Loading layer [==================================================>] 5.3MB/5.3MB
8deb84525956: Loading layer [==================================================>] 64.5MB/64.5MB
5d1431f9963f: Loading layer [==================================================>] 3.072kB/3.072kB
faeb0aac7135: Loading layer [==================================================>] 4.096kB/4.096kB
7ade25e3acdb: Loading layer [==================================================>] 65.29MB/65.29MB
Loaded image: goharbor/chartmuseum-photon:v2.4.2
27495e3181af: Loading layer [==================================================>] 7.222MB/7.222MB
88649dba6134: Loading layer [==================================================>] 7.356MB/7.356MB
875f964b6f85: Loading layer [==================================================>] 1.754MB/1.754MB
Loaded image: goharbor/harbor-portal:v2.4.2
c724cc796747: Loading layer [==================================================>] 124.3MB/124.3MB
b6c853c6dc0d: Loading layer [==================================================>] 3.584kB/3.584kB
0c5772798040: Loading layer [==================================================>] 3.072kB/3.072kB
c5f3bfcfa62d: Loading layer [==================================================>] 2.56kB/2.56kB
2602a8530e9d: Loading layer [==================================================>] 3.072kB/3.072kB
ba9b43b5ffb1: Loading layer [==================================================>] 3.584kB/3.584kB
cf92b578ba00: Loading layer [==================================================>] 20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.4.2
fc1f8cdaf1ce: Loading layer [==================================================>] 1.096MB/1.096MB
eb68e72cbb03: Loading layer [==================================================>] 5.888MB/5.888MB
53a31c9e9836: Loading layer [==================================================>] 166.2MB/166.2MB
bed7172f8681: Loading layer [==================================================>] 17.75MB/17.75MB
c8fcd33ae148: Loading layer [==================================================>] 4.096kB/4.096kB
0c8d734a07ee: Loading layer [==================================================>] 6.144kB/6.144kB
c01db4825573: Loading layer [==================================================>] 3.072kB/3.072kB
4802d0abc8ba: Loading layer [==================================================>] 2.048kB/2.048kB
70bafeb87c65: Loading layer [==================================================>] 2.56kB/2.56kB
376ced88e40e: Loading layer [==================================================>] 2.56kB/2.56kB
0ba55f221469: Loading layer [==================================================>] 2.56kB/2.56kB
55cac263100c: Loading layer [==================================================>] 8.704kB/8.704kB
Loaded image: goharbor/harbor-db:v2.4.2
30ed654bbb0e: Loading layer [==================================================>] 5.301MB/5.301MB
51a81f0bf9ea: Loading layer [==================================================>] 4.096kB/4.096kB
12992ea6b45e: Loading layer [==================================================>] 3.072kB/3.072kB
91b97bcaa9d7: Loading layer [==================================================>] 17.32MB/17.32MB
1a992360f6fa: Loading layer [==================================================>] 18.12MB/18.12MB
Loaded image: goharbor/registry-photon:v2.4.2
d7224235291f: Loading layer [==================================================>] 5.301MB/5.301MB
dd26d9070a7b: Loading layer [==================================================>] 4.096kB/4.096kB
4022ecee5f13: Loading layer [==================================================>] 17.32MB/17.32MB
93d727d0accc: Loading layer [==================================================>] 3.072kB/3.072kB
8a56be8f0b84: Loading layer [==================================================>] 28.69MB/28.69MB
629472303402: Loading layer [==================================================>] 46.81MB/46.81MB
Loaded image: goharbor/harbor-registryctl:v2.4.2
bf4dfb7b7a70: Loading layer [==================================================>] 120.1MB/120.1MB
a0b0ce804b6b: Loading layer [==================================================>] 3.072kB/3.072kB
f088aae660dd: Loading layer [==================================================>] 59.9kB/59.9kB
2c15508db9bd: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.4.2
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /home/bruce/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/registryctl/env
Generated configuration file: /config/portal/nginx.conf
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
loaded secret from file: /data/secret/keys/secretkey
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 harbor-portal ... done
Creating registry ... done
Creating registryctl ... done
Creating redis ... done
Creating harbor-db ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
bruce@bruce-VirtualBox:~/harbor$
3.6 访问
本次是 http://localhost 或者 http://10.0.2.4,账号是 admin,密码是 Harbor12345