欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

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

发布时间:2023/12/31 编程问答 41 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Docker学习笔记08-----Docker Harbor使用详解 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

Docker Harbor使用详解

1、项目

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

Harbor中有两种项目类型:

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

项目创建成功

1.2、指派用户

如果用户不存在,则先创建用户。点击“系统管理->用户管理->新建用户”

录入用户信息,点击“确定”,创建用户

用户创建成功

选择一个项目,选择成员页签,点击“用户”

输入用户,选择用户角色,点击“确定”

角色详细权限

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

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

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

选择用户,点击“其他操作”可以对该用户进行角色修改或从项目中移除该用户

1.4、配置管理

在配置管理页签中,可以对该项目访问级别、部署安全、漏洞扫描等进行配置

1.5、镜像仓库

在镜像仓库页签中,点击“推送命令”可以看到Docker推送命令

1.6、推送镜像
登录仓库
[root@localhost ~]# docker login www.xxx.com.cn: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-storeLogin Succeeded
标记本地仓库
[root@localhost ~]# docker tag 4a97d3158956 www.xxx.com.cn: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 www.xxx.com.cn:4443/itmrl_pub/helloworld 1.0.0 4a97d3158956 3 days ago 659MB
推送镜像
[root@localhost ~]# docker push www.xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0 The push refers to repository [www.xxx.com.cn: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

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 www.yusys-sy.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 www.yusys-sy.com.cn:4443/itmrl_pub/helloworld:1.0.0 www.yusys-sy.com.cn:4443/itmrl_pub/helloworld:1.0.0 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE www.yusys-sy.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 www.xxx.com.cn: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 www.xxx.com.cn: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-storeLogin Succeeded [root@localhost ~]# docker pull www.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 www.xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0 www.xxx.com.cn:4443/itmrl_pub/helloworld:1.0.0

2、日志

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

3、系统管理

3.1、用户管理

维护系统用户

3.2、分布式分发
3.3、标签

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

3.4、项目定额

项目定额功能可以设置项目默认的磁盘空间及每个项目的磁盘空间

3.5、垃圾回收

可以手工或定时执行垃圾回收

同时查看垃圾回收的记录和详细日志

回收记录

详细日志

3.6、配置管理

认证模式

默认认证模式为数据库认证,即用户认证凭证存储在本地数据库。如果使用LDAP来认证用户,则设置为LDAP。

允许自注册

开启自注册功能后可以在登录界面自己注册用户。

配置邮箱服务器

邮箱服务器用于给重置密码的用户发送邮件

按照官方介绍,当用户发起密码修改会发送邮件,但是目前测试并没有发送。在官方Issues中查找可以发现有相关的回复如下:


在v2.2版本中email配置可能会被移除,当前功能并没有使用。

项目创建

用户确定哪些用户有权限创建项目,默认为“所有人”。设置为“仅管理员”则只有管理员可以创建项目。

仓库只读

Harbor被设置为只读模式,在此模式下,不能删除仓库、artifact、 Tag 及推送镜像。

4、日志

日志根路径

/var/log/harbor

总结

以上是生活随笔为你收集整理的Docker学习笔记08-----Docker Harbor使用详解的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。