docker私有仓库harbor的安装及使用

harbor官方文档
环境说明

主机IP
docker192.168.20.135

安装harbor

1.安装docker-compose

[root@docker ~]# yum -y install docker-compose

2.将压缩包解压

[root@docker ~]# cd /usr/src/
[root@docker ~]# wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz

[root@docker ~]# tar xf harbor-offline-installer-v2.0.2.tgz -C /usr/local/

[root@docker ~]# cd /usr/local/harbor

[root@docker harbor]# ls
common.sh             harbor.yml.tmpl  LICENSE
harbor.v2.0.2.tar.gz  install.sh       prepare

3.复制harbor.yml.tmpl文件为harbor.yml

[root@docker harbor]# cp harbor.yml.tmpl harbor.yml

4.修改配置文件

详细配置信息

//改为本机IP
hostname: 192.168.20.135

//没有配置ssl证书就注释掉
# https related config
#https:
  # https port for harbor, default is 443
#  port: 443
  # The path of cert and key files for nginx
#  certificate: /your/certificate/path
#  private_key: /your/private/key/path


//用户名admin,密码Harbor12345
# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345

启动

[root@docker harbor]# systemctl start docker
[root@docker harbor]# ./install.sh ----Harbor has been installed and started successfully.----
[root@docker harbor]# 
[root@docker harbor]# 
[root@docker harbor]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128     *:22                  *:*                  
LISTEN      0      100    127.0.0.1:25                  *:*                  
LISTEN      0      128    127.0.0.1:1514                *:*                  
LISTEN      0      128    :::80                 :::*                  
LISTEN      0      128    :::22                 :::*                  
LISTEN      0      100       ::1:25                 :::*                  

使用Harbor

登入

在这里插入图片描述
在这里插入图片描述
我们可以看到系统各个模块如下:

项目:新增/删除项目,查看镜像仓库,给项目添加成员、查看操作日志、复制项目等
日志:仓库各个镜像create、push、pull等操作日志

系统管理

  • 用户管理:新增/删除用户、设置管理员等
  • 仓库管理:新增/删除从库目标、新建/删除/启停复制规则等
  • 复制管理:认证模式、复制、邮箱设置、系统设置等
  1. 标签
    • 全局级别标签:由系统管理员管理,用于管理整个系统的镜像。它 们可以添加到任何项目下的镜像中。
    • 项目级别标签:由项目管理员或者系统管理员在项目下管理,只能
  2. 添加到本项目的镜像中。
  3. 项目定额:分配每个项目多少存储空间
  4. 审查服务:扫描漏铜
  5. 垃圾清理:清理不需要的镜像
  6. 配置管理:认证设置、邮箱设置、系统设置

注意:非系统管理员用户登录,只能看到有权限的项目和日志,其他模块不可见。
在这里插入图片描述

登录传镜像了

我们需要在/etc/docker/daemon.json加上 “insecure-registries”:[“harborIP”]

[root@docker ~]# vim /etc/docker/daemon.json
[root@docker ~]# cat /etc/docker/daemon.json
{
    "registry-mirrors": ["https://0v0l236l.mirror.aliyuncs.com"],
    "insecure-registries":["192.168.20.135"]
}



//重启服务
[root@docker harbor]# systemctl restart docker


//登入
[root@docker harbor]# docker login 192.168.20.135
Username: admin
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@docker ~]# docker tag nginx:latest 192.168.20.135/nginx/nginx:v0.1


[root@docker ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
192.168.20.135/nginx/nginx      v0.1                4bb46517cac3        2 weeks ago         133MB
nginx                           latest              4bb46517cac3        2 weeks ago         133MB

//上传镜像到harbor仓库

[root@docker ~]# docker push 192.168.20.135/nginx/nginx:v0.1
The push refers to repository [192.168.20.135/nginx/nginx]
550333325e31: Pushed 
22ea89b1a816: Pushed 
a4d893caa5c9: Pushed 
0338db614b95: Pushed 
d0f104dc0a1f: Pushed 
v0.1: digest: sha256:179412c42fe3336e7cdc253ad4a2e03d32f50e3037a860cf5edbeb1aaddb915c size: 1362

在这里插入图片描述

创建用户,分配权限

在这里插入图片描述
添加到nginx项目中,并设置权限
在这里插入图片描述

[root@localhost ~]# vim /etc/docker/daemon.json
{
    "registry-mirrors": ["https://0v0l236l.mirror.aliyuncs.com"],
    "insecure-registries":["192.168.20.135"]
}

[root@localhost ~]# systemctl restart docker

登录

[root@localhost ~]# docker login 192.168.20.135
Username: zzl
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 nginx:latest 192.168.20.135/nginx/nginx:v0.2
[root@localhost ~]# docker push 192.168.20.135/nginx/nginx:v0.2
The push refers to repository [192.168.20.135/nginx/nginx]
550333325e31: Layer already exists 
22ea89b1a816: Layer already exists 
a4d893caa5c9: Layer already exists 
0338db614b95: Layer already exists 
d0f104dc0a1f: Layer already exists 
v0.2: digest: sha256:179412c42fe3336e7cdc253ad4a2e03d32f50e3037a860cf5edbeb1aaddb915c size: 1362

在这里插入图片描述

Docker 镜像复制

harborIP
docker192.168.20.135/24
harbor002192.168.20.99/24

在仓库管理,新建一个目标

在这里插入图片描述

在这里插入图片描述
同步
在这里插入图片描述
在192.168.20.99上查看,同步完成
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值