企业级镜像仓库Harbor

 

介绍:

Habor是由VMWare公司开源的容器镜像仓库。事实上,Habor是在Docker Registry上进行了相应的
企业级扩展,从而获得了更加广泛的应用,这些新的企业级特性包括:管理用户界面,基于角色的访
问控制 ,AD/LDAP集成以及审计日志等,足以满足基本企业需求

组件     功能
harbor-adminserver 配置管理中心
harbor-db MySQL数据库
harbor-jobservice 负责镜像的复制
harbor-log 负责操作日志
harbor-ui Web管理页面和API
nginx 前端代理,负责前端页面和镜像的上传/下载转发
redis 会话
registry 镜像存储

 

 

 

 

 

 

 

 

Harbor的几种安装方式:

1、在线安装:从Docker Hub下载harbor相关镜像,因此安装软件包非常的小

2、离线安装:安装包包含部署的相关镜像,因此安装包比较大

3、OVA安装程序,当用户具有Vcenter环境的时候,使用此安装程序,再部署OVA后启动Harbor

 

这里我们使用离线安装的方式:

harbor-offline-installer-v1.6.1.tgz

tar -xf harbor-offline-installer-v1.6.1.tgz

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
[root@hu-001 harbor]# grep -Ev "^$|^#" harbor.cfg
_version = 1.6.0
hostname = 192.168.20.11 #harbor 的地址,可以写IP,也可以写域名
ui_url_protocol = http
max_job_workers = 10
customize_crt = on
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
secretkey_path = /data
admiral_url = NA
log_rotate_count = 50
log_rotate_size = 200M
http_proxy =
https_proxy =
no_proxy = 127.0.0.1,localhost,ui,registry
email_identity =
email_server = smtp.mydomain.com
email_server_port = 25
email_username = sample_admin@mydomain.com
email_password = abc
email_from = admin <sample_admin@mydomain.com>
email_ssl = false
email_insecure = false
harbor_admin_password = 123456
auth_mode = db_auth
ldap_url = ldaps://ldap.mydomain.com
ldap_basedn = ou=people,dc=mydomain,dc=com
ldap_uid = uid
ldap_scope = 2
ldap_timeout = 5
ldap_verify_cert = true
ldap_group_basedn = ou=group,dc=mydomain,dc=com
ldap_group_filter = objectclass=group
ldap_group_gid = cn
ldap_group_scope = 2
self_registration = on
token_expiration = 30
project_creation_restriction = everyone
db_host = postgresql
db_password = root123
db_port = 5432
db_user = postgres
redis_host = redis
redis_port = 6379
redis_password =
redis_db_index = 1,2,3
clair_db_host = postgresql
clair_db_password = root123
clair_db_port = 5432
clair_db_username = postgres
clair_db = postgres
clair_updaters_interval = 12
uaa_endpoint = uaa.mydomain.org
uaa_clientid = id
uaa_clientsecret = secret
uaa_verify_cert = true
uaa_ca_cert = /path/to/ca.pem
registry_storage_provider_name = filesystem
registry_storage_provider_config =
registry_custom_ca_bundle =

  

Harbor 是使用docker-compose来编排部署的,所以这里我们这里必须要有一个docker-compose

下载后就是一个二进制文件

docker-compose的作用是单机编排,以及管理多个容器

docker-compose-Linux-x86_64

mv docker-compose-Linux-x86_64 harbor/

mv docker-compose-Linux-x86_64 /usr/bin/docker-compose

chmod +x /usr/bin/docker-compose 

[root@hu-001 harbor]# ./prepare   生成预配置文件

[root@hu-001 harbor]# ./install.sh 导入包中所有的镜像

 

假如有什么异常的话,我们处理一下,然后使用docker-compose up -d 再启动一次

这个时候我们浏览器输入:

 

这里默认有一个项目是公开的

这个我们可以不用登陆就可以下载,但是我们上传的时候我们需要创建用户密码,所以这里我们在人员管理上添加一个用户,然后给这个项目分配成员

 

推送镜像的格式:

在项目中标记镜像:

  docker tag SOURCE_IMAGE[:TAG] 192.168.20.11/library/IMAGE[:TAG]

推送镜像到当前项目:
  docker push 192.168.20.11/library/IMAGE[:TAG]

 这里我们先标记镜像,然后把标记的镜像推送到Harbor 仓库中

在推送镜像之前我们需要先登录Harbor

默认是使用https方式的但是我们目前这里使用的事http的方式,所以这里我们要添加一个可信任的配置

[root@hu-001 harbor]# cat /etc/docker/daemon.json
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],
"insecure-registries":["192.168.20.11"]
}

需要重启Docker才可以生效
systemctl restart docker

然后就是登录仓库(使用刚刚web页面上创建的用户名和密码)

1
2
3
4
5
6
7
8
[root@hu-001 harbor]# docker login 192.168.20.11 这里只要登录一次就可以了,但是会有失效时间,其实也不麻烦,每次上传的时候都可以登录一下<br>
Username: bigbao
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
打标签
docker tag nginx:1.15 192.168.20.11/library/bigbao_harbor_nginx:1.15
 
上传镜像到仓库中
[root@hu-001 harbor]# docker push 192.168.20.11/library/bigbao_harbor_nginx:1.15
The push refers to repository [192.168.20.11/library/bigbao_harbor_nginx]
ece4f9fdef59: Pushed
ad5345cbb119: Pushed
ef68f6734aa4: Pushed
1.15: digest: sha256:87e9b6904b4286b8d41bba4461c0b736835fcc218f7ecbe5544b53fdd467189f size: 948

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@hu-001 harbor]# docker images
REPOSITORY                                  TAG                 IMAGE ID            CREATED             SIZE
192.168.20.11/library/bigbao_harbor_nginx   1.15                568c4670fa80        4 days ago          109MB
nginx                                       1.15                568c4670fa80        4 days ago          109MB
nginx                                       latest              568c4670fa80        4 days ago          109MB
goharbor/chartmuseum-photon                 v0.7.1-v1.6.1       f0a2dbee1ff1        6 weeks ago         350MB
goharbor/harbor-migrator                    v1.6.1              60e8be845b35        6 weeks ago         798MB
goharbor/redis-photon                       v1.6.1              6a67380bb061        6 weeks ago         210MB
goharbor/clair-photon                       v2.0.6-v1.6.1       c4fcdbae7df2        6 weeks ago         302MB
goharbor/notary-server-photon               v0.5.1-v1.6.1       f1afd44d9f9b        6 weeks ago         209MB
goharbor/notary-signer-photon               v0.5.1-v1.6.1       83aa51867207        6 weeks ago         207MB
goharbor/registry-photon                    v2.6.2-v1.6.1       f4cb5e83f0a4        6 weeks ago         196MB
goharbor/nginx-photon                       v1.6.1              9ca888fe33b2        6 weeks ago         132MB
goharbor/harbor-log                         v1.6.1              9b1ea3f29465        6 weeks ago         198MB
goharbor/harbor-jobservice                  v1.6.1              9ca6fd371ca6        6 weeks ago         192MB
goharbor/harbor-ui                          v1.6.1              305ee5b8952c        6 weeks ago         215MB
goharbor/harbor-adminserver                 v1.6.1              a3e95f74984e        6 weeks ago         181MB
goharbor/harbor-db                          v1.6.1              3bea3bff0190        6 weeks ago         219MB
centos                                      7                   75835a67d134        7 weeks ago         200MB
busybox                                     latest              59788edf1f3e        2 months ago        1.15MB
[root@hu-001 harbor]# docker tag centos:7 192.168.20.11/library/bigbao_harbor_centos:7
[root@hu-001 harbor]# docker tag busybox:latest 192.168.20.11/library/bigbao_harbor_busybox:latest
[root@hu-001 harbor]# docker push 192.168.20.11/library/bigbao_harbor_busybox:latest
The push refers to repository [192.168.20.11/library/bigbao_harbor_busybox]
8a788232037e: Pushed
latest: digest: sha256:915f390a8912e16d4beb8689720a17348f3f6d1a7b659697df850ab625ea29d5 size: 527
[root@hu-001 harbor]# docker push 192.168.20.11/library/bigbao_harbor_centos:7
The push refers to repository [192.168.20.11/library/bigbao_harbor_centos]
f972d139738d: Pushed
7: digest: sha256:dc29e2bcceac52af0f01300402f5e756cc8c44a310867f6b94f5f7271d4f3fec size: 529

 

这个时候我们去看一下我们的镜像仓库就要镜像了

 

之前我们都是懂官方仓库下载镜像或者加速仓库下载,这个时候我们就可以从自己的私有仓库下载了

这里我们就可以直接只用

docker  pull 192.168.20.11/library/bigbao_harbor_centos:7 下载了(如果不是公开项目我们先登录)

 

posted @   BigBao的博客  阅读(1591)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示