Harbor是一个用于存储和分发Docker镜像的企业级Registry的服务器镜像仓库,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有的Registry中,确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。
基于角色控制 基于镜像的复制策略 支持LDAP/AD 图像删除和垃圾收集 图形UI 审计 RESTful API Proxy 通过一个前置的反向代理统一接受浏览器,Docker客户端的请求,并将请求转发给后端不同的服务 Registry 负责储存Docker镜像,并处理docker push/pull 命令 Core services Harbor的核心功能,包括UI,webhook,token 服务 Database 为core service提供数据库服务 Log collector 负责收集其他组件的log,供日后进行分析
用户请求通过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
#我们本地进行上传镜像 [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
#远程客户端上传镜像到私有仓库 #远程登录会报错 [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
#关闭harbor私有仓库 [root@localhost harbor]# docker-compose down -v [root@localhost harbor]# ./prepare #开启私有仓库 [root@localhost harbor]# docker-compose up -d
#我们用刚才创建的用户来登录私有仓库 [root@localhost harbor]# docker login http://192.168.136.185 Username: chen Password:
docker-compose down -v
/var/log/Harbor/目录下 rm-rf /data/database/ /data/registry/
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。