Docker Private Registry (Harbor)

Docker Private Registry (Harbor)

Harbor

无论是使用Docker-distribution去自建仓库,还是通过官方镜像跑容器的方式去自建仓库,我们可以发现其是非常的简陋的,还不如直接使用官方的Docker Hub去管理镜像来得方便,至少官方的Docker Hub能够通过web界面来管理镜像,还能在web界面执行搜索,还能基于Dockerfile利用Webhooks和Automated Builds实现自动构建镜像的功能,用户不需要在本地执行docker build,而是把所有build上下文的文件作为一个仓库推送到github上,让Docker Hub可以从github上去pull这些文件来完成自动构建。

但无论官方的Docker Hub有多强大,它毕竟是在国外,所以速度是最大的瓶颈,我们很多时候是不可能去考虑使用官方的仓库的,但是上面说的两种自建仓库方式又十分简陋,不便管理,所以后来就出现了一个被 CNCF 组织青睐的项目,其名为Harbor。

Harbor部署
[root@node4 ~]# yum -y install docker-compose

[root@node4 ~]# cd /usr/src/

[root@node4 src]# wget https://github.com/goharbor/harbor/releases/download/v1.10.2/harbor-online-installer-v1.10.2.tgz

[root@node4 src]# ls
debug  harbor-online-installer-v1.10.2.tgz  kernels

[root@node4 src]# tar xf harbor-online-installer-v1.10.2.tgz -C /usr/local/

[root@node4 src]# cd /usr/local/harbor/
[root@node4 harbor]# ls
common.sh  harbor.yml  install.sh  LICENSE  prepare

[root@node4 harbor]# vim harbor.yml

...

hostname: node4.example.com

...

[root@node4 harbor]# ./install.sh

[root@node4 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                                    :::*       

使用IP登录管理Harbor:(密码是Harbor12345,在 harbor.yml里面 )
在这里插入图片描述
在这里插入图片描述
使用Harbor的注意事项:

  1. 在客户端上传镜像时一定要记得执行docker login进行用户认证,否则无法直接push
  2. 在客户端使用的时候如果不是用的https则必须要在客户端的/etc/docker/daemon.json配置文件中配置insecure-registries参数
  3. 数据存放路径应在配置文件中配置到一个容量比较充足的共享存储中
  4. Harbor是使用docker-compose命令来管理的,如果需要停止Harbor也应用docker-compose stop来停止,其他参数请–help

上传镜像

[root@node4 harbor]# docker login node4.example.com
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@node4 harbor]# docker tag bdd7800b2844 node4.example.com/library/httpd:alpine
[root@node4 harbor]# docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
httpd                             alpine              bdd7800b2844        5 hours ago         219MB
node4.example.com/library/httpd   alpine              bdd7800b2844        5 hours ago         219MB
[root@node4 harbor]# docker push node4.example.com/library/httpd:alpine
The push refers to repository [node4.example.com/library/httpd]
7d00f083c71f: Pushed 
f166c8bb046a: Pushed 
beee9f30bc1f: Pushed 
alpine: digest: sha256:507a36ca367ab66b5fb0d1bd9a7384498a01f1d199abc93ff73371fc5b5b15fa size: 951

在这里插入图片描述
删除本地的镜像,看能不能从Harbor上拉下来

[root@node4 harbor]# docker image rm node4.example.com/library/httpd:alpine
Untagged: node4.example.com/library/httpd:alpine
Untagged: node4.example.com/library/httpd@sha256:507a36ca367ab66b5fb0d1bd9a7384498a01f1d199abc93ff73371fc5b5b15fa

[root@node4 harbor]# docker pull node4.example.com/library/httpd:alpine
alpine: Pulling from library/httpd
Digest: sha256:507a36ca367ab66b5fb0d1bd9a7384498a01f1d199abc93ff73371fc5b5b15fa
Status: Downloaded newer image for node4.example.com/library/httpd:alpine
node4.example.com/library/httpd:alpine
[root@node4 harbor]# docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
httpd                             alpine              bdd7800b2844        5 hours ago         219MB
node4.example.com/library/httpd   alpine              bdd7800b2844        5 hours ago         219MB

创建用户
在这里插入图片描述
在这里插入图片描述
使用新创建的用户登录

在这里插入图片描述
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值