[root@opt ~]# wget https://github.com/goharbor/harbor/releases/download/v2.11.1/harbor-offline-installer-v2.11.1.tgz [root@opt ~]# tar -xvf harbor-offline-installer-v2.11.1.tgz
http方式
---
复制配置文件并修改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@harbor ~]# cp harbor.yml.tmpl harbor.yml [root@harbor ~]# vim harbor.yml # 设置域名 hostname: harbor.local.com # 注释https相关配置 # 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
# 克隆项目 [root@tiaoban opt]# git clone https://github.com/Fishdrowned/ssl.git # 一键生成证书 [root@tiaoban opt]# cd ssl [root@tiaoban ssl]# ./gen.cert.sh harbor.local.com # 生成harbor.local.com域名的证书 Removing dir out Creating output structure Done Generating a RSA private key ...................................+++++ ....+++++ writing new private key to 'out/root.key.pem' ----- Generating RSA private key, 2048 bit long modulus (2 primes) .............+++++ ....................................+++++ e is 65537 (0x010001) Using configuration from ./ca.cnf Check that the request matches the signature Signature ok The Subject's Distinguished Name is as follows countryName :PRINTABLE:'CN' stateOrProvinceName :ASN.1 12:'Guangdong' localityName :ASN.1 12:'Guangzhou' organizationName :ASN.1 12:'Fishdrowned' organizationalUnitName:ASN.1 12:'harbor.local.com' commonName :ASN.1 12:'*.harbor.local.com Certificate is to be certified until Aug 12 10:49:02 2025 GMT (730 days)
Write out database with 1 new entries Data Base Updated
[root@harbor ~]# cp harbor.yml.tmpl harbor.yml [root@harbor ~]# vim harbor.yml # 设置域名 hostname: harbor.local.com # 注释http相关配置 # 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: /opt/harbor/harbor.local.com.crt private_key: /opt/harbor/harbor.local.com.key.pem data_volume: /data/harbor
执行安装脚本
---
运行install.sh脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@harbor harbor]# ./install.sh [Step 5]: starting Harbor ... [+] Building 0.0s (0/0) [+] Running 10/10 ✔ Network harbor_harbor Created 0.3s ✔ Container harbor-log Started 1.8s ✔ Container harbor-portal Started 12.8s ✔ Container registry Started 13.1s ✔ Container redis Started 13.2s ✔ Container registryctl Started 11.4s ✔ Container harbor-db Started 12.0s ✔ Container harbor-core Started 14.3s ✔ Container nginx Started 18.2s ✔ Container harbor-jobservice Started 18.1s ✔ ----Harbor has been installed and started successfully.----
[root@tiaoban ~]# docker login harbor.local.com -u admin Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
推送镜像测试
1 2 3 4 5 6 7 8 9 10 11 12
[root@tiaoban ~]# docker pull busybox Using default tag: latest latest: Pulling from library/busybox 5cc84ad355aa: Pull complete Digest: sha256:5acba83a746c7608ed544dc1533b87c737a0b0fb730301639a0179f9344b1678 Status: Downloaded newer image for busybox:latest docker.io/library/busybox:latest [root@tiaoban ~]# docker tag busybox:latest harbor.local.com/library/busybox:latest [root@tiaoban ~]# docker push harbor.local.com/library/busybox:latest The push refers to repository [harbor.local.com/library/busybox] 01fd6df81c8e: Pushed latest: digest: sha256:62ffc2ed7554e4c6d360bce40bbcf196573dd27c4ce080641a2c59867e732dee size: 527
[root@master1 ~]# nerdctl login -u admin -p Harbor12345 --insecure-registry harbor.local.com WARN[0000] WARNING! Using --password via the CLI is insecure. Use --password-stdin. WARN[0000] skipping verifying HTTPS certs for "harbor.local.com" WARNING: Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store