github: https://github.com/goharbor/harbor
官網:https://goharbor.io/docs/2.5.0/
[安裝]
1. 檢視是否達到安裝條件

2.根據實際情況選擇 線上版本和離線版本
- Online installer: The online installer downloads the Harbor images from Docker hub. For this reason, the installer is very small in size.
- Offline installer: Use the offline installer if the host to which are deploying Harbor does not have a connection to the Internet. The offline installer contains pre-built images, so it is larger than the online installer.
我這裡使用的線上版本進行安裝:
3.下載下傳并安裝
wget https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-online-installer-v2.5.0.tgz
tar -zxvf harbor-online-installer-v2.5.0.tgz
修改配置檔案:
mv harbor.yml.tmpl harbor.yml
vim harbor.yml
如果配置的域名或使用指定的端口的話, 需要修改 hostname:
如果80端口有占用的話, 需要修改參數: port
如果沒有使用https的話, 需要将參數進行注釋: https 部分
extenal_url: 可以與hostname 保持一緻
注意點: 可以修改這裡的admin登入的密碼 harbor_admin_password
安裝:
./install.sh
打開web界面 進行登入
1)建立項目(共有,私有)
2)使用者管理 > 建立使用者
3)将使用者綁定到指定的倉庫下
使用:
1) 登入
docker login -u xxx -p xxx xx.xxx.com
例如:
[root@localhost src]# docker login 192.168.139.132
Username: caixin
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
[root@localhost src]#
2)鏡像推送
先進行打tag
[root@localhost src]# docker tag nginx:1.18.0 192.168.139.132/library/nginx:1.18.0
[root@localhost src]# docker tag mysql:5.7.32 192.168.139.132/library/mysql:5.7.32
[root@localhost src]# docker tag php:5.6-fpm 192.168.139.132/library/php:5.6-fpm
[root@localhost src]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.139.132/library/nginx 1.18.0 c2c45d506085 12 months ago 133MB
nginx 1.18.0 c2c45d506085 12 months ago 133MB
192.168.139.132/library/mysql 5.7.32 cc8775c0fe94 15 months ago 449MB
mysql 5.7.32 cc8775c0fe94 15 months ago 449MB
192.168.139.132/library/php 5.6-fpm 3458979c7744 3 years ago 344MB
php 5.6-fpm 3458979c7744 3 years ago 344MB
goharbor/chartmuseum-photon v0.7.1-v1.7.0 666d74cc236a 3 years ago 111MB
goharbor/harbor-migrator v1.7.0 482699d98927 3 years ago 799MB
goharbor/redis-photon v1.7.0 8adff755797f 3 years ago 96.1MB
goharbor/clair-photon v2.0.7-v1.7.0 7e72f6ba05bd 3 years ago 165MB
goharbor/notary-server-photon v0.6.1-v1.7.0 b4a22960dfce 3 years ago 102MB
goharbor/notary-signer-photon v0.6.1-v1.7.0 bb0db7ebd1de 3 years ago 99.6MB
goharbor/harbor-registryctl v1.7.0 1906a8b84fa5 3 years ago 101MB
goharbor/registry-photon v2.6.2-v1.7.0 677f21b09362 3 years ago 86.4MB
goharbor/nginx-photon v1.7.0 6ed96fc73f83 3 years ago 35.5MB
goharbor/harbor-log v1.7.0 722fa4a77846 3 years ago 81MB
goharbor/harbor-jobservice v1.7.0 effd390c0cd4 3 years ago 83.8MB
goharbor/harbor-core v1.7.0 2ebd58ce5638 3 years ago 95.2MB
goharbor/harbor-portal v1.7.0 72a291f86bab 3 years ago 40.2MB
goharbor/harbor-adminserver v1.7.0 9f850341a571 3 years ago 72MB
goharbor/harbor-db v1.7.0 45d94fe5fee5 3 years ago 133MB
docker/compose 1.18.0 8a01ec091f90 4 years ago 19.2MB
[root@localhost src]#
3)推送
[root@localhost src]# docker push 192.168.139.132/library/nginx:1.18.0
[root@localhost src]# docker push 192.168.139.132/library/mysql:5.7.32
The push refers to repository [192.168.139.132/library/mysql]
df1ee06a30c4: Pushed
902dedce4cb4: Pushed
569a2d6e5302: Pushed
8bdb6ee41f57: Pushed
98d98806c8ac: Pushed
0394a41efa73: Pushed
c484a3b6d841: Pushed
6d23902c2a54: Pushed
74c86dffd46f: Pushed
ef4a33cee7a0: Pushed
cb42413394c4: Pushed
5.7.32: digest: sha256:860f4bcc18607de9f40a7453c7dc160313ecc3a5a46be3b060569b6216d348f6 size: 2621
[root@localhost src]#
[root@localhost src]# docker push 192.168.139.132/library/php:5.6-fpm
The push refers to repository [192.168.139.132/library/php]
bf97b47da88d: Pushed
56d6009fbc8b: Pushed
b6d5993da6a4: Pushed
c9e57440aae2: Pushed
5e2afcdec12b: Pushed
6e4f2e72b0d9: Pushed
6eb3cfd4ad9e: Pushed
82bded2c3a7c: Pushed
b87a266e6a9c: Pushed
3c816b4ead84: Pushed
5.6-fpm: digest: sha256:7cfd6ccb875ff314b2c672b62aa3169fe79d54bf3422b7b0017955b3457ca1a7 size: 2410
[root@localhost src]#
就可以在harbor中檢視到推送上去的鏡像了
# 登入
docker login http://harbor.xxx.com
# 打标簽
docker tag hello:v1 harbor.xxx.com/library/docker-hello:v1.0.0
# 推送鏡像
docker push harbor.xxx.com/library/docker-hello:v1.0.0
# 推送鏡像
docker pull harbor.xxx.com/library/docker-hello:v1.0.0
如果出現無法登入的錯誤, 需要配置倉庫位址, 在配置檔案中添加/etc/docker/daemon.json
{
...
"insecure-registries": ["http://harbor.xxx.com"]
}
重新開機生效
systemctl daemon-reload
systemctl restart docker
vim /usr/local/nginx/conf/nginx.conf
http {
...
client_max_body_size 1024m;
}