博客列表 >harbor安装

harbor安装

哈
原创
2022年07月20日 11:32:20755浏览

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

系统版本:CentOS Linux release 7.6.1810 (Core)

docker版本:20.10.12

docker-compose版本:v2.3.2

一、安装docker-compose:

把在百度网盘下载的docker-compose文件到服务器里

  1. [root@zabbix 14:57:42~]# chmod +x docker-compose-linux-x86_64
  2. [root@zabbix 14:57:48~]# mv docker-compose-linux-x86_64 /usr/local/sbin/docker-compose

二、安装harbor

1、上传在百度网盘下载的harbor压缩包文件到服务器里:

  1. [root@zabbix 14:58:29/data/recycle]# ll
  2. total 1237904
  3. -rw-r--r-- 1 root root 612698835 Mar 9 14:59 harbor-offline-installer-v2.4.1.tgz
  4. [root@zabbix 14:59:20/data/recycle]#

2、解压harbor:

  1. [root@zabbix 14:59:20/data/recycle]# tar zxf harbor-offline-installer-v2.4.1.tgz
  2. [root@zabbix 14:59:30/data/recycle]# ll
  3. total 1237908
  4. drwxr-xr-x 2 root root 4096 Mar 9 14:59 harbor
  5. -rw-r--r-- 1 root root 612698835 Mar 9 14:59 harbor-offline-installer-v2.4.1.tgz

3、移动到部署目录:

  1. [root@zabbix 14:59:47/data/recycle]# mv harbor /data/software/
  2. [root@zabbix 14:59:54/data/recycle]# cd /data/software/harbor/
  3. [root@zabbix 15:00:00/data/software/harbor]# ll
  4. total 601612
  5. -rw-r--r-- 1 root root 3361 Dec 16 12:22 common.sh
  6. -rw-r--r-- 1 root root 616006217 Dec 16 12:23 harbor.v2.4.1.tar.gz
  7. -rw-r--r-- 1 root root 8999 Dec 16 12:22 harbor.yml.tmpl
  8. -rwxr-xr-x 1 root root 2500 Dec 16 12:22 install.sh
  9. -rw-r--r-- 1 root root 11347 Dec 16 12:22 LICENSE
  10. -rwxr-xr-x 1 root root 1881 Dec 16 12:22 prepare

4、修改配置文件

  1. [root@zabbix 15:00:06/data/software/harbor]# cp harbor.yml.tmpl harbor.yml

vim harbor.yml

file

5、修改daemon,并添加http的通信地址,不然docker默认使用https进行通信,如果配置了https协议就不需要添加

  1. ## 如果不修改,可能会碰到如下错误,只是不一定
  2. ## [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd".
  1. [root@zabbix 16:08:52/data/software/harbor]# cat /etc/docker/daemon.json
  2. {
  3. "registry-mirrors": ["https://nr240upq.mirror.aliyuncs.com", "https://registry.docker-cn.com", "https://docker.mirrors.ustc.edu.cn", "https://dockerhub.azk8s.cn", "http://hub-mirror.c.163.com"],
  4. "exec-opts": ["native.cgroupdriver=systemd"],
  5. "log-driver": "json-file",
  6. "log-opts": {
  7. "max-size": "100m"
  8. },
  9. "insecure-registries": ["172.17.0.100:5000"]
  10. }
  11. [root@zabbix 16:16:59/data/software/harbor]#

file

改好之后,重新加载配置和重启docker

  1. [root@zabbix 15:00:50/data/software/harbor]# systemctl daemon-reload && systemctl restart docker

6、执行部署脚本:./install.sh

  1. [root@zabbix 15:03:56/data/software/harbor]# ./install.sh
  2. [Step 0]: checking if docker is installed ...
  3. Note: docker version: 20.10.12
  4. [Step 1]: checking docker-compose is installed ...
  5. Note: docker-compose version: 2.3.2
  6. [Step 2]: loading Harbor images ...
  7. 1e3f0dc884e2: Loading layer [==================================================>] 39.45MB/39.45MB
  8. 3fd9ccd5eeaa: Loading layer [==================================================>] 5.275MB/5.275MB
  9. c600bceee2f7: Loading layer [==================================================>] 4.096kB/4.096kB
  10. 724cd8711815: Loading layer [==================================================>] 3.072kB/3.072kB
  11. d7c82a981c89: Loading layer [==================================================>] 17.32MB/17.32MB
  12. a814341c2c44: Loading layer [==================================================>] 18.12MB/18.12MB
  13. Loaded image: goharbor/registry-photon:v2.4.1
  14. b00595b6932d: Loading layer [==================================================>] 5.27MB/5.27MB
  15. e34892d856ce: Loading layer [==================================================>] 5.928MB/5.928MB
  16. ac5a22c6047d: Loading layer [==================================================>] 14.47MB/14.47MB
  17. 3d1ac12eb215: Loading layer [==================================================>] 29.29MB/29.29MB
  18. 394b4b2ea0fa: Loading layer [==================================================>] 22.02kB/22.02kB
  19. bb0deb7416e0: Loading layer [==================================================>] 14.47MB/14.47MB
  20. Loaded image: goharbor/notary-signer-photon:v2.4.1
  21. c3b02aec560c: Loading layer [==================================================>] 8.422MB/8.422MB
  22. 4d5b3acd128e: Loading layer [==================================================>] 3.584kB/3.584kB
  23. 7afbf44c3706: Loading layer [==================================================>] 2.56kB/2.56kB
  24. 31f95ac6eb9a: Loading layer [==================================================>] 75.59MB/75.59MB
  25. 8981a12f5c17: Loading layer [==================================================>] 5.632kB/5.632kB
  26. 16eb0821dcc3: Loading layer [==================================================>] 96.26kB/96.26kB
  27. b19eba29a0de: Loading layer [==================================================>] 11.78kB/11.78kB
  28. f0785d2e9965: Loading layer [==================================================>] 76.49MB/76.49MB
  29. 26ce29b9d7ab: Loading layer [==================================================>] 2.56kB/2.56kB
  30. Loaded image: goharbor/harbor-core:v2.4.1
  31. 59e3814aa5f1: Loading layer [==================================================>] 119.8MB/119.8MB
  32. 1e99e9cd580e: Loading layer [==================================================>] 3.072kB/3.072kB
  33. 2bab205001c7: Loading layer [==================================================>] 59.9kB/59.9kB
  34. c51450af480c: Loading layer [==================================================>] 61.95kB/61.95kB
  35. Loaded image: goharbor/redis-photon:v2.4.1
  36. 3636ff090145: Loading layer [==================================================>] 8.421MB/8.421MB
  37. fa3d57c372c8: Loading layer [==================================================>] 3.584kB/3.584kB
  38. a2c97825dcbf: Loading layer [==================================================>] 2.56kB/2.56kB
  39. 366b1363b528: Loading layer [==================================================>] 86.95MB/86.95MB
  40. 3d2fd6d13a0f: Loading layer [==================================================>] 87.74MB/87.74MB
  41. Loaded image: goharbor/harbor-jobservice:v2.4.1
  42. 8f71cf8bc1c6: Loading layer [==================================================>] 5.275MB/5.275MB
  43. 5cb3457d8e25: Loading layer [==================================================>] 4.096kB/4.096kB
  44. 02c18fad9dc6: Loading layer [==================================================>] 17.32MB/17.32MB
  45. 7bbcea1ec44e: Loading layer [==================================================>] 3.072kB/3.072kB
  46. f2842e1ada70: Loading layer [==================================================>] 28.69MB/28.69MB
  47. 4665575c3f9e: Loading layer [==================================================>] 46.81MB/46.81MB
  48. Loaded image: goharbor/harbor-registryctl:v2.4.1
  49. 439595cfbbc0: Loading layer [==================================================>] 7.192MB/7.192MB
  50. Loaded image: goharbor/nginx-photon:v2.4.1
  51. a19de03ace6b: Loading layer [==================================================>] 5.27MB/5.27MB
  52. 35bbd4cf35b6: Loading layer [==================================================>] 5.928MB/5.928MB
  53. 88f852ebd746: Loading layer [==================================================>] 15.88MB/15.88MB
  54. e3c0db81a28c: Loading layer [==================================================>] 29.29MB/29.29MB
  55. f74e521b7a55: Loading layer [==================================================>] 22.02kB/22.02kB
  56. 7d97a705f439: Loading layer [==================================================>] 15.88MB/15.88MB
  57. Loaded image: goharbor/notary-server-photon:v2.4.1
  58. 1e6473070b18: Loading layer [==================================================>] 124MB/124MB
  59. f05c1a477d2d: Loading layer [==================================================>] 3.584kB/3.584kB
  60. bcab3e00aa98: Loading layer [==================================================>] 3.072kB/3.072kB
  61. 970d569f474a: Loading layer [==================================================>] 2.56kB/2.56kB
  62. c659c9812277: Loading layer [==================================================>] 3.072kB/3.072kB
  63. 9d401ff8bf07: Loading layer [==================================================>] 3.584kB/3.584kB
  64. 968dfed00d2e: Loading layer [==================================================>] 19.97kB/19.97kB
  65. Loaded image: goharbor/harbor-log:v2.4.1
  66. b64000a1cd2c: Loading layer [==================================================>] 1.097MB/1.097MB
  67. e3fb7ac15701: Loading layer [==================================================>] 5.889MB/5.889MB
  68. d6e7f8008582: Loading layer [==================================================>] 165.9MB/165.9MB
  69. eff0812a8c6f: Loading layer [==================================================>] 15.07MB/15.07MB
  70. 91a6abd7a540: Loading layer [==================================================>] 4.096kB/4.096kB
  71. 47e875926154: Loading layer [==================================================>] 6.144kB/6.144kB
  72. 04876e025d4a: Loading layer [==================================================>] 3.072kB/3.072kB
  73. b817a88114e6: Loading layer [==================================================>] 2.048kB/2.048kB
  74. e5fb37021dff: Loading layer [==================================================>] 2.56kB/2.56kB
  75. 767486d5c318: Loading layer [==================================================>] 2.56kB/2.56kB
  76. b92f2b842b46: Loading layer [==================================================>] 2.56kB/2.56kB
  77. e90e3a7ea4e9: Loading layer [==================================================>] 8.704kB/8.704kB
  78. Loaded image: goharbor/harbor-db:v2.4.1
  79. daf3d38cddc8: Loading layer [==================================================>] 8.422MB/8.422MB
  80. 8013b2cbc0b9: Loading layer [==================================================>] 18.13MB/18.13MB
  81. 4445f5ea7083: Loading layer [==================================================>] 4.608kB/4.608kB
  82. 32e035f0af8e: Loading layer [==================================================>] 18.93MB/18.93MB
  83. Loaded image: goharbor/harbor-exporter:v2.4.1
  84. 0ad72e88d766: Loading layer [==================================================>] 8.54MB/8.54MB
  85. fe195f48d47b: Loading layer [==================================================>] 4.096kB/4.096kB
  86. 71f2671db231: Loading layer [==================================================>] 3.072kB/3.072kB
  87. ddda0b4a8eae: Loading layer [==================================================>] 39.27MB/39.27MB
  88. c3fe76027866: Loading layer [==================================================>] 12.37MB/12.37MB
  89. d82a7403c39a: Loading layer [==================================================>] 52.43MB/52.43MB
  90. Loaded image: goharbor/trivy-adapter-photon:v2.4.1
  91. 03e449493f09: Loading layer [==================================================>] 5.275MB/5.275MB
  92. 4f4a25c7cc0d: Loading layer [==================================================>] 64.5MB/64.5MB
  93. 77a37df05436: Loading layer [==================================================>] 3.072kB/3.072kB
  94. 47c58e48962d: Loading layer [==================================================>] 4.096kB/4.096kB
  95. 5dd56c28f3fc: Loading layer [==================================================>] 65.29MB/65.29MB
  96. Loaded image: goharbor/chartmuseum-photon:v2.4.1
  97. 8b7cbddd8918: Loading layer [==================================================>] 165.6MB/165.6MB
  98. b8157b6f7cb8: Loading layer [==================================================>] 57.6MB/57.6MB
  99. 4a53b9a92b30: Loading layer [==================================================>] 2.56kB/2.56kB
  100. 59184fc56c3c: Loading layer [==================================================>] 1.536kB/1.536kB
  101. 99431fe2c10f: Loading layer [==================================================>] 12.29kB/12.29kB
  102. 3735b7f4881f: Loading layer [==================================================>] 2.62MB/2.62MB
  103. bcff3633b236: Loading layer [==================================================>] 325.6kB/325.6kB
  104. Loaded image: goharbor/prepare:v2.4.1
  105. eb57d0945b2e: Loading layer [==================================================>] 7.192MB/7.192MB
  106. dd9069fd53a8: Loading layer [==================================================>] 7.355MB/7.355MB
  107. e779dab1d180: Loading layer [==================================================>] 1.754MB/1.754MB
  108. Loaded image: goharbor/harbor-portal:v2.4.1
  109. [Step 3]: preparing environment ...
  110. [Step 4]: preparing harbor configs ...
  111. prepare base dir is set to /data/software/harbor
  112. WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
  113. Generated configuration file: /config/portal/nginx.conf
  114. Generated configuration file: /config/log/logrotate.conf
  115. Generated configuration file: /config/log/rsyslog_docker.conf
  116. Generated configuration file: /config/nginx/nginx.conf
  117. Generated configuration file: /config/core/env
  118. Generated configuration file: /config/core/app.conf
  119. Generated configuration file: /config/registry/config.yml
  120. Generated configuration file: /config/registryctl/env
  121. Generated configuration file: /config/registryctl/config.yml
  122. Generated configuration file: /config/db/env
  123. Generated configuration file: /config/jobservice/env
  124. Generated configuration file: /config/jobservice/config.yml
  125. Generated and saved secret to file: /data/secret/keys/secretkey
  126. Successfully called func: create_root_cert
  127. Generated configuration file: /compose_location/docker-compose.yml
  128. Clean up the input dir
  129. [Step 5]: starting Harbor ...
  130. [+] Running 10/10
  131. ? Network harbor_harbor Created 0.0s
  132. ? Container harbor-log Started 0.6s
  133. ? Container redis Started 1.3s
  134. ? Container registryctl Started 1.4s
  135. ? Container registry Started 1.4s
  136. ? Container harbor-db Started 1.4s
  137. ? Container harbor-portal Started 1.3s
  138. ? Container harbor-core Started 1.7s
  139. ? Container harbor-jobservice Started 2.3s
  140. ? Container nginx Started 2.4s
  141. ? ----Harbor has been installed and started successfully.----
  142. [root@zabbix 15:04:47/data/software/harbor]#

7、配置开机自启:

  1. /usr/local/sbin/docker-compose -f /data/software/harbor/docker-compose.yml up -d

file

8、设置权限

  1. chmod +x /etc/rc.local /etc/rc.d/rc.local

9、尝试登陆harbor

file

10、命令行登陆

  1. [root@zabbix 15:08:00/data/software/harbor]# docker login 172.17.0.100:5000
  2. Username: admin
  3. Password:
  4. Login Succeeded
  5. [root@zabbix 15:08:57/data/software/harbor]#

三、测试上传和下载

1、新建一个项目目录:

file

file

file

file

2、我以nginx为例进行推送到harbor上:

  1. [root@zabbix 16:45:33/data/software/harbor]# docker image ls | grep nginx
  2. nginx latest 605c77e624dd 2 months ago 141MB
  3. goharbor/nginx-photon v2.4.1 78aad8c8ef41 2 months ago 45.7MB
  4. [root@zabbix 16:45:42/data/software/harbor]# docker tag nginx:latest 172.17.0.100:5000/test/nginx1.8:v1
  5. [root@zabbix 16:59:00/data/software/harbor]# docker image ls | grep nginx
  6. 172.17.0.100:5000/test/nginx1.8 v1 605c77e624dd 2 months ago 141MB
  7. nginx latest 605c77e624dd 2 months ago 141MB
  8. goharbor/nginx-photon v2.4.1 78aad8c8ef41 2 months ago 45.7MB
  9. [root@zabbix 16:59:04/data/software/harbor]# docker push 172.17.0.100:5000/test/nginx1.8:v1
  10. The push refers to repository [172.17.0.100:5000/test/nginx1.8]
  11. d874fd2bc83b: Pushed
  12. 32ce5f6a5106: Pushed
  13. f1db227348d0: Pushed
  14. b8d6e692a25e: Pushed
  15. e379e8aedd4d: Pushed
  16. 2edcec3590a4: Pushed
  17. v1: digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3 size: 1570
  18. [root@zabbix 16:59:25/data/software/harbor]#

3、查看镜像仓库,可以看到多了一个镜像

file

4、镜像拉取(镜像下载)

  1. [root@zabbix 16:59:25/data/software/harbor]# docker image rm 172.17.0.100:5000/test/nginx1.8:v1
  2. Untagged: 172.17.0.100:5000/test/nginx1.8:v1
  3. Untagged: 172.17.0.100:5000/test/nginx1.8@sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
  4. [root@zabbix 17:01:15/data/software/harbor]# docker image ls | grep nginx
  5. nginx latest 605c77e624dd 2 months ago 141MB
  6. goharbor/nginx-photon v2.4.1 78aad8c8ef41 2 months ago 45.7MB
  7. [root@zabbix 17:02:07/data/software/harbor]# docker pull 172.17.0.100:5000/test/nginx1.8:v1
  8. v1: Pulling from test/nginx1.8
  9. Digest: sha256:ee89b00528ff4f02f2405e4ee221743ebc3f8e8dd0bfd5c4c20a2fa2aaa7ede3
  10. Status: Downloaded newer image for 172.17.0.100:5000/test/nginx1.8:v1
  11. 172.17.0.100:5000/test/nginx1.8:v1
  12. [root@zabbix 17:02:12/data/software/harbor]# docker image ls | grep nginx
  13. 172.17.0.100:5000/test/nginx1.8 v1 605c77e624dd 2 months ago 141MB
  14. nginx latest 605c77e624dd 2 months ago 141MB
  15. goharbor/nginx-photon v2.4.1 78aad8c8ef41 2 months ago 45.7MB
  16. [root@zabbix 17:02:16/data/software/harbor]#

至此,harbor部署完毕

知识补充:

1、如果以后修改了harbor.yml文件,那么先停止使用docker-compose down,再去修改harbor.yml文件,重新启动部署 ./install.sh

2、正常启动harbor启动:

  1. docker-compose up -d

3、未修改配置文件,重启Harbor命令:docker-compose start | stop | restart

原文链接:https://blog.csdn.net/moyuanbomo/article/details/123378825

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议