docker搭建和使用harbor私有仓库
admin
2023-02-02 05:41:58
0次

本文在介绍关于docker搭建和使用harbor私有仓库的基础上,重点探讨了其具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。

Docker私有仓库架构拓扑

docker搭建和使用harbor私有仓库
用户请求通过Proxy反向代理访问Core services,UI提供web界面,token令牌,你第一次登录之后服务器会给你一串序列号,下次直接登录就行,你需要下载的镜像信息,属性,都存放在后面的database,再通过webhook回调去registry私有仓库调取镜像。这一系列的操作都存放在日志中。

搭建harbor私有仓库

harbor被部署为多个docker容器,因此可以部署在任何支持docker的linux的发行版上
我们还需要docker-compose编排工具,编排工具执行了多个docker容器的操作
[root@localhost ~]# mount.cifs //192.168.100.25/compose /abc/
Password for root@//192.168.100.25/compose:  
[root@localhost ~]# cd /abc/
[root@localhost abc]# ls
consul_0.9.2_linux_amd64.zip  consul-template_0.19.3_linux_amd64.zip  docker-compose
[root@localhost abc]# cp docker-compose /usr/local/bin/

[root@localhost abc]# tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/

[root@localhost abc]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd harbor/
[root@localhost harbor]# ls
common                     docker-compose.yml     harbor.v1.2.2.tar.gz  NOTICE
docker-compose.clair.yml   harbor_1_1_0_template  install.sh            prepare
docker-compose.notary.yml  harbor.cfg             LICENSE               upgrade

hostname = 192.168.136.185

#开启私有仓库
[root@localhost harbor]# sh /usr/local/harbor/install.sh

[root@localhost harbor]# docker-compose ps

#如果一切正常,可以打开浏览器访问http://192.168.136.185 的管理页面
默认用户名密码是:admin,Harbor12345

我们先创建一个项目,我们的一类镜像可以放在里面

docker搭建和使用harbor私有仓库
docker搭建和使用harbor私有仓库

#我们本地进行上传镜像
[root@localhost harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1

[root@localhost harbor]# docker pull cirros

[root@localhost harbor]# docker tag cirros 127.0.0.1/chen/cirros:v1
[root@localhost harbor]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
127.0.0.1/chen/cirros       v1                  bc94bceaae77        12 months ago       10.3MB
cirros                      latest              bc94bceaae77        12 months ago       10.3MB

[root@localhost harbor]# docker push 127.0.0.1/chen/cirros:v1
The push refers to repository [127.0.0.1/chen/cirros]
abbd6d6ac643: Pushed 
75b99987219d: Pushed 
0cc237193a30: Pushed 
v1: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f19446bd size: 943

我们通过web界面查看一下镜像有没有上传成功

docker搭建和使用harbor私有仓库

#远程客户端上传镜像到私有仓库
#远程登录会报错
[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://192.168.136.185/v2/: dial tcp 192.168.136.185:443: connect: connection refused
#我们要指定私有仓库实列
[root@localhost ~]# vim /usr/lib/systemd/system/docker.service 
14 ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.136.185 --containerd=/run/contai    nerd/containerd.sock

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185

#远程下载私有仓库的镜像
[root@localhost ~]# docker pull 192.168.136.185/chen/cirros:v1

#远程上传镜像到私有仓库
[root@localhost ~]# docker push 192.168.136.185/chen/cirros:v2
The push refers to repository [192.168.136.185/chen/cirros]
abbd6d6ac643: Layer already exists 
75b99987219d: Layer already exists 
0cc237193a30: Layer already exists 
v2: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f

网页验证

docker搭建和使用harbor私有仓库

#关闭harbor私有仓库

[root@localhost harbor]# docker-compose down -v

[root@localhost harbor]# ./prepare 

#开启私有仓库
[root@localhost harbor]# docker-compose up -d

创建用户

docker搭建和使用harbor私有仓库

#我们用刚才创建的用户来登录私有仓库
[root@localhost harbor]# docker login http://192.168.136.185
Username: chen
Password: 

在项目中我们加入一个用户

docker搭建和使用harbor私有仓库docker搭建和使用harbor私有仓库

如果要移除服务容器同时保留镜像数据库/数据库

docker-compose down -v

如需重新部署,需要移除harbor服务容器全部数据

/var/log/Harbor/目录下
rm-rf /data/database/ /data/registry/

以上就是docker搭建和使用harbor私有仓库的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎关注行业资讯!


相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...