Docker学习笔记08-----Docker Harbor使用详解

Docker Harbor使用详解

1、项目

项目包含了一个应用的所有仓库,项目未被创建之前镜像不能推送到Harbor。只有被授权的用户才可以对该项目进行操作。

Harbor中有两种项目类型:

  • 公开: 任何用户都可以从这个项目中拉取镜像
  • 私有: 仅项目成员可以从这个项目中拉取镜像
1.1、新建项目
项目->新建项目

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qvHtp8Kg-1614673980642)(404389716D7142F5BC3B78317C39FA3A)]

项目创建成功

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1Rh4synF-1614673980644)(75C80B5C4AF64FEF8125FF1C7B8ED71E)]

1.2、指派用户

如果用户不存在,则先创建用户。点击“系统管理->用户管理->新建用户”
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Gk5u53NF-1614673980645)(7979A440ED1542969830B3E101772F0D)]
录入用户信息,点击“确定”,创建用户
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XQd6G1ns-1614673980647)(1D951CC9055E49BDAE7E7E9A39D6917D)]
用户创建成功
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wivvT1zW-1614673980648)(31C3590221144E7B9FFB81823F3D9969)]
选择一个项目,选择成员页签,点击“用户”
在这里插入图片描述
输入用户,选择用户角色,点击“确定”
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JgeISAPl-1614673980650)(4FF028A9C44641CE824506D07B259B65)]
角色详细权限

https://goharbor.io/docs/1.10/administration/managing-users/user-permissions-by-role/

总体来说角色权限分为访客、开发者、管理者。

  • 访客: 用于拉取镜像
  • 开发者:用于拉取镜像用于拉取、推送镜像
  • 管理者:用于管理平台。
1.3、修改角色或移除用户

选择用户,点击“其他操作”可以对该用户进行角色修改或从项目中移除该用户
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1HipgkmZ-1614673980651)(E91F6207A8B9459DA4CC320B4FEA940E)]

1.4、配置管理

在配置管理页签中,可以对该项目访问级别、部署安全、漏洞扫描等进行配置
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hbTk9xng-1614673980652)(143B32882DBC4CF68E7F346EEFD275FF)]

1.5、镜像仓库

在镜像仓库页签中,点击“推送命令”可以看到Docker推送命令
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-AA2C5HpN-1614673980653)(8883FF30E3604537A7CD34CD4371426F)]

1.6、推送镜像
登录仓库
[root@localhost ~]# docker login 127.0.0.1:4443
Username: dev_user
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 ~]# docker tag 4a97d3158956 127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
[root@localhost ~]# docker images
REPOSITORY                                               TAG                 IMAGE ID            CREATED             SIZE
helloworld                                               1.0.0               4a97d3158956        3 days ago          659MB
127.0.0.1:4443/itmrl_pub/helloworld            1.0.0               4a97d3158956        3 days ago          659MB
推送镜像
[root@localhost ~]# docker push 127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
The push refers to repository [127.0.0.1:4443/itmrl_pub/helloworld]
7ecd0eab9c73: Pushed 
35c20f26d188: Pushed 
c3fe59dd9556: Pushed 
6ed1a81ba5b6: Pushed 
a3483ce177ce: Pushed 
ce6c8756685b: Pushed 
30339f20ced0: Pushed 
0eb22bfb707d: Pushed 
a2ae92ffcd29: Pushed 
1.0.0: digest: sha256:74ed6579c9e1e874fe73da2a50e1b0e15dc78a67de533aa0c39facf3bfbba296 size: 2212

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qyPFDQrc-1614673980653)(A55A65CF1CB04E898D10B4F38E1515FD)]

1.7、拉取镜像
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               5.7                 a70d36bc331a        6 weeks ago         449MB
mysql               latest              c8562eaf9d81        6 weeks ago         546MB
tomcat              latest              040bdb29ab37        6 weeks ago         649MB
tomcat              8.5.32              5808f01b11bf        2 years ago         463MB
java                8                   d23bdf5b1b1b        4 years ago         643MB
[root@localhost ~]# docker pull xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0
1.0.0: Pulling from itmrl_pub/helloworld
7448db3b31eb: Already exists 
c36604fa7939: Already exists 
29e8ef0e3340: Already exists 
a0c934d2565d: Already exists 
a360a17c9cab: Already exists 
cfcc996af805: Already exists 
2cf014724202: Already exists 
4bc402a00dfe: Already exists 
353d55df259a: Pull complete 
Digest: sha256:74ed6579c9e1e874fe73da2a50e1b0e15dc78a67de533aa0c39facf3bfbba296
Status: Downloaded newer image for xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0
xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0
[root@localhost ~]# docker images
REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE
xxx.com.cn:4443/itmrl_pub/helloworld   1.0.0               4a97d3158956        3 days ago          659MB
mysql                                           5.7                 a70d36bc331a        6 weeks ago         449MB
mysql                                           latest              c8562eaf9d81        6 weeks ago         546MB
tomcat                                          latest              040bdb29ab37        6 weeks ago         649MB
tomcat                                          8.5.32              5808f01b11bf        2 years ago         463MB
java                                            8                   d23bdf5b1b1b        4 years ago         643MB
修改项目访问权限为私有,再次拉取
[root@localhost ~]# docker pull 127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
Error response from daemon: unauthorized: unauthorized to access repository: itmrl_pub/helloworld, action: pull: unauthorized to access repository: itmrl_pub/helloworld, action: pull
登录后再次拉取
[root@localhost ~]# docker login 127.0.0.1:4443
Username: dev_user
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 ~]# docker pull 127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
1.0.0: Pulling from itmrl_pub/helloworld
7448db3b31eb: Already exists 
c36604fa7939: Already exists 
29e8ef0e3340: Already exists 
a0c934d2565d: Already exists 
a360a17c9cab: Already exists 
cfcc996af805: Already exists 
2cf014724202: Already exists 
4bc402a00dfe: Already exists 
353d55df259a: Pull complete 
Digest: sha256:74ed6579c9e1e874fe73da2a50e1b0e15dc78a67de533aa0c39facf3bfbba296
Status: Downloaded newer image for 127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
127.0.0.1:4443/itmrl_pub/helloworld:1.0.0
2、日志

日志功能可以查看操作的日志

3、系统管理
3.1、用户管理

维护系统用户

3.2、分布式分发
3.3、标签

创建标签,用于给镜像打标签

3.4、项目定额

项目定额功能可以设置项目默认的磁盘空间及每个项目的磁盘空间
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HOHE7qjg-1614673980654)(C1A6BDA9359749D883816E9CFDDD8126)]

3.5、垃圾回收

可以手工或定时执行垃圾回收
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eRMf2R5g-1614673980655)(DFD0A46389484CFA9CCFD4CC6C1CDBE6)]
同时查看垃圾回收的记录和详细日志

回收记录
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WAFml4Sa-1614673980656)(0A4F56A81D874C11ABB0962BD43AF75F)]
详细日志
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Z03JyMcK-1614673980657)(7A50AB2CB25A4E43AE0A3C3CB41CF7F1)]

3.6、配置管理

认证模式

默认认证模式为数据库认证,即用户认证凭证存储在本地数据库。如果使用LDAP来认证用户,则设置为LDAP。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MqAG8Mma-1614673980657)(CFA915857A914BF4AEDC60E4A0C36BC8)]
允许自注册

开启自注册功能后可以在登录界面自己注册用户。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ttYHNega-1614673980658)(0699C82844F64EDDBB65FBC213D3717D)]
配置邮箱服务器

邮箱服务器用于给重置密码的用户发送邮件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-6TKIhOVE-1614673980659)(3296077C395B46CBB90E6799EBD53583)]
按照官方介绍,当用户发起密码修改会发送邮件,但是目前测试并没有发送。在官方Issues中查找可以发现有相关的回复如下:

在这里插入图片描述
在v2.2版本中email配置可能会被移除,当前功能并没有使用。

项目创建

用户确定哪些用户有权限创建项目,默认为“所有人”。设置为“仅管理员”则只有管理员可以创建项目。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-W4gKJNvy-1614673980660)(D323DD1956FF4D8F82FA6CAC1D183341)]
仓库只读

Harbor被设置为只读模式,在此模式下,不能删除仓库、artifact、 Tag 及推送镜像。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-IIaN7qrZ-1614673980660)(40E4BFA6EB024924962806B271E02823)]

4、日志

日志根路径

/var/log/harbor
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

itmrl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值