淘先锋技术网

首页 1 2 3 4 5 6 7

一、概述

1、Docker Harbor有可视化的Web管理界面,可以方便管理Docker镜像,又提供了多个项目的镜像权限管理及控制功能。
2、Harbor的优势

  • 基于角色控制
  • 基于镜像的复制策略
  • 支持LDAP/AD
  • 图像删除和垃圾收集
  • 图形Ul
  • 审计
  • RESTful APl

3、Harbpr被部署为多个Docker容器,因此可以部署在任何支持Docker的 Linux发行版上。( registry 为其核心组件)
4、Harbor 比 registry相比好处是: harbor支持多种功能、图形化界面管理、多用户权限、角色管理机制、安全机制。

二、部署

[root@harbor ~]# cd /opt
[root@harbor opt]# rz
#上传harbor-offline-installer-v1.2.2.tgz
[root@harbor opt]# tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/
[root@harbor opt]# vim /usr/local/harbor/harbor.cfg #修改配置文件
第5行 hostname = 192.168.238.100

[root@harbor ~]# docker-compose -v #查看compose是否安装
docker-compose version 1.21.1, build 5a3f1a3
[root@harbor ~]# sh /usr/local/harbor/install.sh

在这里插入图片描述

[root@harbor harbor]# docker-compose ps #查看容器
       Name                     Command               State                                                       Ports                                                    
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver   /harbor/harbor_adminserver       Up                                                                                                                   
harbor-db            docker-entrypoint.sh mysqld      Up      3306/tcp                                                                                                     
harbor-jobservice    /harbor/harbor_jobservice        Up                                                                                                                   
harbor-log           /bin/sh -c crond && rm -f  ...   Up      127.0.0.1:1514->514/tcp                                                                                      
harbor-ui            /harbor/harbor_ui                Up                                                                                                                   
nginx                nginx -g daemon off;             Up      0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:4443->4443/tcp,:::4443->4443/tcp,                              
                                                              0.0.0.0:80->80/tcp,:::80->80/tcp                                                                             
registry             /entrypoint.sh serve /etc/ ...   Up      5000/tcp 

访问192.168。238.100,用户admin,密码Harbor12345在这里插入图片描述
创建项目harbor,并设置为公开
在这里插入图片描述

一、本地登录harbor

[root@harbor harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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

二、指定ip登录

[root@harbor harbor]# vim /usr/lib/systemd/system/docker.service

在这里插入图片描述

[root@harbor harbor]# systemctl daemon-reload
[root@harbor harbor]# systemctl restart docker
[root@harbor harbor]# docker login -u admin -p Harbor12345 http://192.168.238.100
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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@harbor harbor]# docker pull cirros
Using default tag: latest
latest: Pulling from library/cirros
d0b405be7a32: Pull complete 
bd054094a037: Pull complete 
c6a00de1ec8a: Pull complete 
Digest: sha256:1e695eb2772a2b511ccab70091962d1efb9501fdca804eb1d52d21c0933e7f47
Status: Downloaded newer image for cirros:latest
docker.io/library/cirros:latest
[root@harbor harbor]# docker images
REPOSITORY                  TAG               IMAGE ID       CREATED         SIZE
nginx                       latest            822b7ec2aaf2   8 days ago      133MB
cirros                      latest            f9cae1daf5f6   6 months ago    12.6MB
centos                      7                 8652b9f0cb4c   10 months ago   204MB
vmware/harbor-log           v1.2.2            36ef78ae27df   3 years ago     200MB
vmware/harbor-jobservice    v1.2.2            e2af366cba44   3 years ago     164MB
vmware/harbor-ui            v1.2.2            39efb472c253   3 years ago     178MB
vmware/harbor-adminserver   v1.2.2            c75963ec543f   3 years ago     142MB
vmware/harbor-db            v1.2.2            ee7b9fa37c5d   3 years ago     329MB
vmware/nginx-photon         1.11.13           6cc5c831fc7f   3 years ago     144MB
vmware/registry             2.6.2-photon      5d9100e4350e   4 years ago     173MB
vmware/postgresql           9.6.4-photon      c562762cbd12   4 years ago     225MB
vmware/clair                v2.0.1-photon     f04966b4af6c   4 years ago     297MB
vmware/harbor-notary-db     mariadb-10.1.10   64ed814665c6   4 years ago     324MB
vmware/notary-photon        signer-0.5.0      b1eda7d10640   4 years ago     156MB
vmware/notary-photon        server-0.5.0      6e2646682e3c   4 years ago     157MB
photon                      1.0               e6e4e4a2ba1b   5 years ago     128MB

四、上传镜像

[root@harbor harbor]# docker tag cirros:latest  192.168.238.100/harbor/cirros:test #打标签
[root@harbor harbor]# docker push 192.168.238.100/harbor/cirros:test #上传镜像
The push refers to repository [192.168.238.100/harbor/cirros]
984ad441ec3d: Pushed 
f0a496d92efa: Pushed 
e52d19c3bee2: Pushed 
test: digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22 size: 943

在这里插入图片描述

五、删除镜像

[root@harbor harbor]# docker rmi 192.168.238.100/harbor/cirros:test #删除

[root@harbor harbor]# docker pull 192.168.238.100/harbor/cirros:test #从私有仓库下载
test: Pulling from harbor/cirros
Digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22
Status: Downloaded newer image for 192.168.238.100/harbor/cirros:test
192.168.238.100/harbor/cirros:test

[root@harbor harbor]# docker images #查看镜像
REPOSITORY                      TAG               IMAGE ID       CREATED         SIZE
nginx                           latest            822b7ec2aaf2   8 days ago      133MB
192.168.238.100/harbor/cirros   test              f9cae1daf5f6   6 months ago    12.6MB
cirros                          latest            f9cae1daf5f6   6 months ago    12.6MB
centos                          7                 8652b9f0cb4c   10 months ago   204MB
vmware/harbor-log               v1.2.2            36ef78ae27df   3 years ago     200MB
vmware/harbor-jobservice        v1.2.2            e2af366cba44   3 years ago     164MB
vmware/harbor-ui                v1.2.2            39efb472c253   3 years ago     178MB
vmware/harbor-adminserver       v1.2.2            c75963ec543f   3 years ago     142MB
vmware/harbor-db                v1.2.2            ee7b9fa37c5d   3 years ago     329MB
vmware/nginx-photon             1.11.13           6cc5c831fc7f   3 years ago     144MB
vmware/registry                 2.6.2-photon      5d9100e4350e   4 years ago     173MB
vmware/postgresql               9.6.4-photon      c562762cbd12   4 years ago     225MB
vmware/clair                    v2.0.1-photon     f04966b4af6c   4 years ago     297MB
vmware/harbor-notary-db         mariadb-10.1.10   64ed814665c6   4 years ago     324MB
vmware/notary-photon            signer-0.5.0      b1eda7d10640   4 years ago     156MB
vmware/notary-photon            server-0.5.0      6e2646682e3c   4 years ago     157MB
photon                          1.0               e6e4e4a2ba1b   5 years ago     128MB