1 环境
2 docker 与 docker-compose
bruce@bruce-VirtualBox:~/harbor$ docker -v & docker-compose -v[1] 36159Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2docker-compose version 1.25.0, build unknown[1]+ 已完成 docker -vbruce@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 confighttp:# port for http, default is 80. If https enabled, this port will redirect to https portport: 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 configurationdatabase:# 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 volumedata_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 vulnerabilitiesignore_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 certificateinsecure: 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: xxxjobservice:# Maximum number of job workers in job servicemax_job_workers: 10notification:# Maximum retry count for webhook jobwebhook_job_max_retry: 10chart:# Change the value of absolute_url to enabled can enable absolute url in chartabsolute_url: disabled# Log configurationslog:# options are debug, info, warning, error, fatallevel: info# configs for logs in local storagelocal:# 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 loglocation: /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/harborUnable to find image 'goharbor/prepare:v2.4.2' locallyv2.4.2: Pulling from goharbor/prepare6c964f3b879f: Pull complete3042f4284e2c: Pull complete7a91ea24644b: Pull completeb3c79e094a18: Pull complete110443f7949d: Pull complete1fbee02500d7: Pull complete8675c3a61fe1: Pull completed48514bf9c2b: Pull completeDigest: sha256:b14da6252672c596291f02a5e76fbb065f558aaf0a647f90e1c77aefaa29db74Status: Downloaded newer image for goharbor/prepare:v2.4.2WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to httpsGenerated configuration file: /config/portal/nginx.confGenerated configuration file: /config/log/logrotate.confGenerated configuration file: /config/log/rsyslog_docker.confGenerated configuration file: /config/nginx/nginx.confGenerated configuration file: /config/core/envGenerated configuration file: /config/core/app.confGenerated configuration file: /config/registry/config.ymlGenerated configuration file: /config/registryctl/envGenerated configuration file: /config/registryctl/config.ymlGenerated configuration file: /config/db/envGenerated configuration file: /config/jobservice/envGenerated configuration file: /config/jobservice/config.ymlGenerated and saved secret to file: /data/secret/keys/secretkeySuccessfully called func: create_root_certGenerated configuration file: /compose_location/docker-compose.ymlClean up the input dirbruce@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.296MB43ad630c07b8: Loading layer [==================================================>] 5.928MB/5.928MB3457e72d7725: Loading layer [==================================================>] 14.47MB/14.47MB4a079b4b377a: Loading layer [==================================================>] 29.29MB/29.29MB7b180b7bf3b4: Loading layer [==================================================>] 22.02kB/22.02kB7b678649a1be: Loading layer [==================================================>] 14.47MB/14.47MBLoaded image: goharbor/notary-signer-photon:v2.4.24f650960b0dc: Loading layer [==================================================>] 5.832MB/5.832MB967788659fd5: Loading layer [==================================================>] 4.096kB/4.096kB30cc19bdf2d6: Loading layer [==================================================>] 3.072kB/3.072kB9ccede1a4324: Loading layer [==================================================>] 47.85MB/47.85MB86f4685faff0: Loading layer [==================================================>] 12.38MB/12.38MB25af1cf9c44e: Loading layer [==================================================>] 61.02MB/61.02MBLoaded image: goharbor/trivy-adapter-photon:v2.4.2Loaded image: goharbor/prepare:v2.4.2323ed00cae7e: Loading layer [==================================================>] 8.447MB/8.447MBc3f8c4668352: Loading layer [==================================================>] 3.584kB/3.584kB94b71cd07106: Loading layer [==================================================>] 2.56kB/2.56kB5d5638decfe4: Loading layer [==================================================>] 75.6MB/75.6MB48426521f41c: Loading layer [==================================================>] 5.632kB/5.632kBbb977315930e: Loading layer [==================================================>] 97.28kB/97.28kB2a80a5f64ee7: Loading layer [==================================================>] 11.78kB/11.78kB0a5146355ed0: Loading layer [==================================================>] 76.5MB/76.5MB7d5eac57d5fa: Loading layer [==================================================>] 2.56kB/2.56kBLoaded image: goharbor/harbor-core:v2.4.2f7cedf07c50c: Loading layer [==================================================>] 8.447MB/8.447MBb2a916599ac7: Loading layer [==================================================>] 3.584kB/3.584kB3bc2556f46f8: Loading layer [==================================================>] 2.56kB/2.56kBa9cc192089ec: Loading layer [==================================================>] 86.96MB/86.96MB9e9c53c1bd85: Loading layer [==================================================>] 87.75MB/87.75MBLoaded image: goharbor/harbor-jobservice:v2.4.26111e09009c2: Loading layer [==================================================>] 7.222MB/7.222MBLoaded image: goharbor/nginx-photon:v2.4.2f4658d2c3aa3: Loading layer [==================================================>] 8.447MB/8.447MB4b7bdcad271f: Loading layer [==================================================>] 18.13MB/18.13MBcbb8c130a490: Loading layer [==================================================>] 4.608kB/4.608kBf1367013643c: Loading layer [==================================================>] 18.93MB/18.93MBLoaded image: goharbor/harbor-exporter:v2.4.2a1b12e0ab8ea: Loading layer [==================================================>] 5.296MB/5.296MBdf6629a5ee28: Loading layer [==================================================>] 5.928MB/5.928MB944fcde3a84b: Loading layer [==================================================>] 15.88MB/15.88MB300e181c27cf: Loading layer [==================================================>] 29.29MB/29.29MB87f01e78dde1: Loading layer [==================================================>] 22.02kB/22.02kB8306283aa89d: Loading layer [==================================================>] 15.88MB/15.88MBLoaded image: goharbor/notary-server-photon:v2.4.2c635aace513a: Loading layer [==================================================>] 5.3MB/5.3MB8deb84525956: Loading layer [==================================================>] 64.5MB/64.5MB5d1431f9963f: Loading layer [==================================================>] 3.072kB/3.072kBfaeb0aac7135: Loading layer [==================================================>] 4.096kB/4.096kB7ade25e3acdb: Loading layer [==================================================>] 65.29MB/65.29MBLoaded image: goharbor/chartmuseum-photon:v2.4.227495e3181af: Loading layer [==================================================>] 7.222MB/7.222MB88649dba6134: Loading layer [==================================================>] 7.356MB/7.356MB875f964b6f85: Loading layer [==================================================>] 1.754MB/1.754MBLoaded image: goharbor/harbor-portal:v2.4.2c724cc796747: Loading layer [==================================================>] 124.3MB/124.3MBb6c853c6dc0d: Loading layer [==================================================>] 3.584kB/3.584kB0c5772798040: Loading layer [==================================================>] 3.072kB/3.072kBc5f3bfcfa62d: Loading layer [==================================================>] 2.56kB/2.56kB2602a8530e9d: Loading layer [==================================================>] 3.072kB/3.072kBba9b43b5ffb1: Loading layer [==================================================>] 3.584kB/3.584kBcf92b578ba00: Loading layer [==================================================>] 20.48kB/20.48kBLoaded image: goharbor/harbor-log:v2.4.2fc1f8cdaf1ce: Loading layer [==================================================>] 1.096MB/1.096MBeb68e72cbb03: Loading layer [==================================================>] 5.888MB/5.888MB53a31c9e9836: Loading layer [==================================================>] 166.2MB/166.2MBbed7172f8681: Loading layer [==================================================>] 17.75MB/17.75MBc8fcd33ae148: Loading layer [==================================================>] 4.096kB/4.096kB0c8d734a07ee: Loading layer [==================================================>] 6.144kB/6.144kBc01db4825573: Loading layer [==================================================>] 3.072kB/3.072kB4802d0abc8ba: Loading layer [==================================================>] 2.048kB/2.048kB70bafeb87c65: Loading layer [==================================================>] 2.56kB/2.56kB376ced88e40e: Loading layer [==================================================>] 2.56kB/2.56kB0ba55f221469: Loading layer [==================================================>] 2.56kB/2.56kB55cac263100c: Loading layer [==================================================>] 8.704kB/8.704kBLoaded image: goharbor/harbor-db:v2.4.230ed654bbb0e: Loading layer [==================================================>] 5.301MB/5.301MB51a81f0bf9ea: Loading layer [==================================================>] 4.096kB/4.096kB12992ea6b45e: Loading layer [==================================================>] 3.072kB/3.072kB91b97bcaa9d7: Loading layer [==================================================>] 17.32MB/17.32MB1a992360f6fa: Loading layer [==================================================>] 18.12MB/18.12MBLoaded image: goharbor/registry-photon:v2.4.2d7224235291f: Loading layer [==================================================>] 5.301MB/5.301MBdd26d9070a7b: Loading layer [==================================================>] 4.096kB/4.096kB4022ecee5f13: Loading layer [==================================================>] 17.32MB/17.32MB93d727d0accc: Loading layer [==================================================>] 3.072kB/3.072kB8a56be8f0b84: Loading layer [==================================================>] 28.69MB/28.69MB629472303402: Loading layer [==================================================>] 46.81MB/46.81MBLoaded image: goharbor/harbor-registryctl:v2.4.2bf4dfb7b7a70: Loading layer [==================================================>] 120.1MB/120.1MBa0b0ce804b6b: Loading layer [==================================================>] 3.072kB/3.072kBf088aae660dd: Loading layer [==================================================>] 59.9kB/59.9kB2c15508db9bd: Loading layer [==================================================>] 61.95kB/61.95kBLoaded image: goharbor/redis-photon:v2.4.2[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...prepare base dir is set to /home/bruce/harborWARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to httpsClearing the configuration file: /config/jobservice/envClearing the configuration file: /config/jobservice/config.ymlClearing the configuration file: /config/nginx/nginx.confClearing the configuration file: /config/log/logrotate.confClearing the configuration file: /config/log/rsyslog_docker.confClearing the configuration file: /config/core/app.confClearing the configuration file: /config/core/envClearing the configuration file: /config/registry/passwdClearing the configuration file: /config/registry/config.ymlClearing the configuration file: /config/portal/nginx.confClearing the configuration file: /config/db/envClearing the configuration file: /config/registryctl/config.ymlClearing the configuration file: /config/registryctl/envGenerated configuration file: /config/portal/nginx.confGenerated configuration file: /config/log/logrotate.confGenerated configuration file: /config/log/rsyslog_docker.confGenerated configuration file: /config/nginx/nginx.confGenerated configuration file: /config/core/envGenerated configuration file: /config/core/app.confGenerated configuration file: /config/registry/config.ymlGenerated configuration file: /config/registryctl/envGenerated configuration file: /config/registryctl/config.ymlGenerated configuration file: /config/db/envGenerated configuration file: /config/jobservice/envGenerated configuration file: /config/jobservice/config.ymlloaded secret from file: /data/secret/keys/secretkeyGenerated configuration file: /compose_location/docker-compose.ymlClean up the input dir[Step 5]: starting Harbor ...Creating network "harbor_harbor" with the default driverCreating harbor-log ... doneCreating harbor-portal ... doneCreating registry ... doneCreating registryctl ... doneCreating redis ... doneCreating harbor-db ... doneCreating harbor-core ... doneCreating nginx ... doneCreating 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
