docker-harbor私有仓库部署和管理

harbor:开源的企业级的docker仓库软件

仓库:私有仓库 公有仓库 (公司内部一般都是私有仓库)

habor 是有图形化的,页面UI展示的一个工具,操作起来很直观。

harbor每个组件都是由容器构建的,所以安装harbor必须要有docker

docker-compose 一键编排,所以也是需要安装的。

harbor:

1、通过角色对权限进行控制,用户和仓库都是基于项目进行组织,不同的用户在不同的项目中拥有不同的权限

2、镜像复制,每个仓库(之间可以通信)之间可以互相复制里面的镜像

3、UI界面可以对镜像进行删除,删除了之后也会释放本机的空间

4、图形化界面,可以用浏览器进行访问

5、审计管理,所有对镜像仓库的操作都有记录,用于审计管理


harbor的组件:

主要的组件:

1、porxy:nginx的前端页面,nginx的配置中做了反向代理,浏览器不同的请求转发到后端不同的容器中。

2、Registry:仓库,保存镜像,同时push上传/pull下载(核心功能)

3、core services:Harbor的核心功能,对用户进行授权,检测仓库内镜像的变化以及token,根据不同的权限给予不同的token(token相当于身份的认证)

4、database:负责存储用户的权限,审计日志,docker镜像的分组信息

5、JOB services:镜像复制,不同仓库之间进行复制

6、log collector:日志收集工具

以上组件都是由容器运行,docker-compose一键拉取部署


实验环节

客户端:docker

服务端1:harbor docker docker-compose

服务端2:harbor docker docker-compose

1、部署服务端

2、客户端和服务器之间上传,下载镜像,权限控制(重要)

3、仓库之间的镜像复制。(服务器迁移用得到)

拖入harbor-offline-installer-v2.8.1.tgz 压缩包

对其进行解压tar -xf

解压完成出现harbor这个目录,进入这个目录中,查看这个目录中的文件

出现一个harbor.yml.tmpl这个文件,对其进行备份,备份的文件名称为harbor.yml

对harbor.yml配置文件进行编辑

在第5行修改一下ip地址为192.168.124.10

5 hostname: 192.168.124.70

 第13行至18行把https注释掉

13 #https:
 14   # https port for harbor, default is 443
 15   #port: 443
 16   # The path of cert and key files for nginx
 17   #certificate: /your/certificate/path
 18   #private_key: /your/private/key/path

第34行管理员的密码可更改也可以不改,改成自己熟悉的密码

34 harbor_admin_password: 123456

 第53行data_volume:上传到仓库之后,仓库保存的镜像路径

53 data_volume: /data

 ./prepare 安装和拉取harbor依赖的镜像

Unable to find image 'goharbor/prepare:v2.8.1' locally
v2.8.1: Pulling from goharbor/prepare
fae4a5262fc3: Pull complete
9349e879c799: Pull complete
f70ee3e2dda4: Pull complete
e4481ec28daf: Pull complete
5e2207505ae9: Pull complete
8a696946fd36: Pull complete
31fd4a582b38: Pull complete
940005f64c71: Pull complete
bac5bba6e7f3: Pull complete
93231c0f7f57: Pull complete
Digest: sha256:22f96c244c2b0644dadc8049f8a49847e76e946743e12f78f69eac682ece4fc9
Status: Downloaded newer image for goharbor/prepare:v2.8.1
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

./install.sh执行harbor软件里面的脚本安装相关软件

✔ ----Harbor has been installed and started successfully.----

 在浏览器访问192.168.124.70这个页面

往库里面的项目上传镜像

进入这个harbor库中命令

[root@localhost harbor]# docker login -u admin -p 123456 http://192.168.124.70

先把镜像打上一个标签

 docker tag nginx:1.22 192.168.124.70/test1/nginx:v1

必须以192.168.124.70/test1/nginx:v1这种格式,不然浏览器的库识别不了

然后往库中的项目上传镜像

[root@localhost harbor]# docker push 192.168.124.70/test1/nginx:v1
The push refers to repository [192.168.124.70/test1/nginx]
9543dec06aa8: Pushed
ccf4f419ba49: Pushed
21f8452ebfb1: Pushed
25bbf4633bb3: Pushed
a4f34e6fb432: Pushed
3af14c9a24c9: Pushed
v1: digest: sha256:9081064712674ffcff7b7bdf874c75bcb8e5fb933b65527026090dacda36ea8b size: 1570

角色:

1、先添加用户,用户就是一个普通用户,私有项目是无法浏览的

2、要浏览私有项目,必须要项目中添加成员,设定成员的角色

受限访客:只能看,不能上传,也不能下载,也没有其他权限

访客:拥有只读权限,可以拉取镜像,不能上传,也无法删除镜像

开发者:可以读写,但是不能删除

维护人员:既有读写权限,也可以对项目的权限进行修改

项目管理员:读写,修改,删除都可以

在docker.service配置添加ip地址

vim /usr/lib/systemd/system/docker.service

项目迁移

安装harbor

安装配置docker-compose

1 mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
2 chmod 777 /usr/local/bin/docker-compose
3 docker-compose -v
4 Docker Compose version v2.18.0
5 tar -xf harbor-offline-installer-v2.8.1.tgz
6 ls
7 containerd  harbor  harbor-offline-installer-v2.8.1.tgz  rh
8 cd harbor
9 ls
10 common.sh  harbor.v2.8.1.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
11 cp harbor.yml.tmpl harbor.yml
12 vim harbor.yml
13 ./prepare #编译环境
14 ./install.sh   ##开始安装
#如果需要修改harbor配置文件重新./install.sh在执行一次即可

进入页面

复制管理新建规则

如果不选则拉取所有

  • 15
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值