• Docker----harbor服务


    目录

     一、harbor简介

    二、harbor服务部署

    1、上传文件至opt目录下

    2、解压到安装目录

    3、配置harbor的参数文件

    4、执行运行脚本

    5、查看

    三、验证 

    1、下载一个小点的镜像,方便实验

    2、通过命令行登录Harbor

    3、给需要上传的镜像打tag标记

    4、上传至harbor仓库


    本篇实验基于docker-compose篇之后,否则无法完成

     一、harbor简介

            Harbor 是由 VMware 开源的一款云原生制品仓库,Harbor 的核心功能是存储和管理 Artifact。Harbor 允许用户用命令行工具对容器镜像及其他 Artifact 进行推送和拉取,并提供了图形管理界面帮助用户查看和管理这些 Artifact。(registry 为其核心组件)

            Harbor 比 registry相比好处是: harbor支持多种功能、图形化界面管理、多用户权限、角色管理机制、安全机制。registry为纯字符界面形式。

            环境需求:服务端主机需要安装 Python、Docker和Docker Compose。(web环境支持的是PY语言,故需要安装 Python)

    二、harbor服务部署

    1、上传文件至opt目录下

    1. [root@zwb_docker opt]# rz -E
    2. rz waiting to receive.
    3. harbor-offline-installer-v1.2.2.tgz rh

    2、解压到安装目录

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

    3、配置harbor的参数文件

    [root@zwb_docker harbor]# pwd                 ## 当前位置
    /usr/local/harbor
    [root@zwb_docker harbor]# vim harbor.cfg  

    4、执行运行脚本

    [root@zwb_docker harbor]# sh install.sh 

    1. [root@zwb_docker harbor]# sh install.sh
    2. [Step 0]: checking installation environment ...
    3. Note: docker version: 20.10.18
    4. Note: docker-compose version: 1.14.0
    5. [Step 1]: loading Harbor images ...
    6. dd60b611baaa: Loading layer 133.2MB/133.2MB
    7. abf0579c40fd: Loading layer 1.536kB/1.536kB
    8. ea1fc7bed9c5: Loading layer 22.48MB/22.48MB
    9. 1d6671367c69: Loading layer 7.168kB/7.168kB
    10. b322bb3e4765: Loading layer 5.339MB/5.339MB
    11. 0cf512d418ac: Loading layer 9.728kB/9.728kB
    12. 4a7cdc0b1a2b: Loading layer 2.56kB/2.56kB
    13. ef1130526636: Loading layer 22.48MB/22.48MB
    14. Loaded image: vmware/harbor-ui:v1.2.2
    15. 4a050fccec52: Loading layer 12.16MB/12.16MB
    16. d918d73369ec: Loading layer 17.3MB/17.3MB
    17. 22898836924e: Loading layer 15.87kB/15.87kB
    18. Loaded image: vmware/notary-photon:server-0.5.0
    19. 76c156eab077: Loading layer 134MB/134MB
    20. 1eae6563289a: Loading layer 16.42MB/16.42MB
    21. Loaded image: vmware/nginx-photon:1.11.13
    22. 2e814f7ef645: Loading layer 2.048kB/2.048kB
    23. bc5742b580db: Loading layer 2.048kB/2.048kB
    24. 5413bcdb81b0: Loading layer 2.56kB/2.56kB
    25. c4e2be066795: Loading layer 3.584kB/3.584kB
    26. a4ea62be60b0: Loading layer 22.8MB/22.8MB
    27. 800a351ae5da: Loading layer 22.8MB/22.8MB
    28. Loaded image: vmware/registry:2.6.2-photon
    29. Loaded image: photon:1.0
    30. a39bd6a7f897: Loading layer 10.95MB/10.95MB
    31. 6f79b8337a1f: Loading layer 17.3MB/17.3MB
    32. 74bbd0e81dd0: Loading layer 15.87kB/15.87kB
    33. Loaded image: vmware/notary-photon:signer-0.5.0
    34. 2202528221a2: Loading layer 7.07MB/7.07MB
    35. 4fe250d3c912: Loading layer 7.07MB/7.07MB
    36. Loaded image: vmware/harbor-adminserver:v1.2.2
    37. 9463fb852970: Loading layer 75.37MB/75.37MB
    38. d2c9a2a395d9: Loading layer 3.584kB/3.584kB
    39. b08aea2a8a82: Loading layer 3.072kB/3.072kB
    40. 103e65a1013b: Loading layer 3.072kB/3.072kB
    41. Loaded image: vmware/harbor-log:v1.2.2
    42. 5d6cbe0dbcf9: Loading layer 129.2MB/129.2MB
    43. 435f2dfbd884: Loading layer 344.6kB/344.6kB
    44. 814d7b59f0cc: Loading layer 4.657MB/4.657MB
    45. aae399245bd0: Loading layer 1.536kB/1.536kB
    46. 21e2ae955f72: Loading layer 33.84MB/33.84MB
    47. a2d0f7b84059: Loading layer 25.09kB/25.09kB
    48. 819fa6af55b8: Loading layer 3.584kB/3.584kB
    49. 78914c99a468: Loading layer 167.7MB/167.7MB
    50. 36e79c658afb: Loading layer 6.144kB/6.144kB
    51. f73503aca003: Loading layer 9.216kB/9.216kB
    52. a21b39f6da59: Loading layer 1.536kB/1.536kB
    53. ef81eb7c77b3: Loading layer 8.704kB/8.704kB
    54. 08d0cfe60b0d: Loading layer 4.608kB/4.608kB
    55. 0864dda8f611: Loading layer 4.608kB/4.608kB
    56. Loaded image: vmware/harbor-db:v1.2.2
    57. 29d1f4ae97dd: Loading layer 18.31MB/18.31MB
    58. 7caf936e1402: Loading layer 18.31MB/18.31MB
    59. Loaded image: vmware/harbor-jobservice:v1.2.2
    60. 78dbfa5b7cbc: Loading layer 130.9MB/130.9MB
    61. 5f70bf18a086: Loading layer 1.024kB/1.024kB
    62. 8deec01122be: Loading layer 344.6kB/344.6kB
    63. 574ab36807f2: Loading layer 1.536kB/1.536kB
    64. d8f2cde2eef8: Loading layer 20.48kB/20.48kB
    65. eaa3924b054e: Loading layer 5.12kB/5.12kB
    66. 8aa2c772121c: Loading layer 184.3MB/184.3MB
    67. c3014bbccb0b: Loading layer 8.704kB/8.704kB
    68. 978a35efaa8c: Loading layer 4.608kB/4.608kB
    69. c2385ae7d6e5: Loading layer 16.6MB/16.6MB
    70. Loaded image: vmware/harbor-notary-db:mariadb-10.1.10
    71. c192a34d4ff4: Loading layer 155.2MB/155.2MB
    72. d012a9276a83: Loading layer 10.75MB/10.75MB
    73. b8befd881cb5: Loading layer 10.75MB/10.75MB
    74. Loaded image: vmware/clair:v2.0.1-photon
    75. bbda1562018e: Loading layer 101.6MB/101.6MB
    76. 1171ab08cc04: Loading layer 6.656kB/6.656kB
    77. 6df81d3a0683: Loading layer 6.656kB/6.656kB
    78. Loaded image: vmware/postgresql:9.6.4-photon
    79. [Step 2]: preparing environment ...
    80. Clearing the configuration file: ./common/config/adminserver/env
    81. Clearing the configuration file: ./common/config/ui/env
    82. Clearing the configuration file: ./common/config/ui/app.conf
    83. Clearing the configuration file: ./common/config/ui/private_key.pem
    84. Clearing the configuration file: ./common/config/db/env
    85. Clearing the configuration file: ./common/config/jobservice/env
    86. Clearing the configuration file: ./common/config/jobservice/app.conf
    87. Clearing the configuration file: ./common/config/registry/config.yml
    88. Clearing the configuration file: ./common/config/registry/root.crt
    89. Clearing the configuration file: ./common/config/nginx/nginx.conf
    90. loaded secret from file: /data/secretkey
    91. Generated configuration file: ./common/config/nginx/nginx.conf
    92. Generated configuration file: ./common/config/adminserver/env
    93. Generated configuration file: ./common/config/ui/env
    94. Generated configuration file: ./common/config/registry/config.yml
    95. Generated configuration file: ./common/config/db/env
    96. Generated configuration file: ./common/config/jobservice/env
    97. Generated configuration file: ./common/config/jobservice/app.conf
    98. Generated configuration file: ./common/config/ui/app.conf
    99. Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
    100. The configuration files are ready, please use docker-compose to start the service.
    101. [Step 3]: checking existing instance of Harbor ...
    102. [Step 4]: starting Harbor ...
    103. Creating harbor-log ...
    104. Creating harbor-log ... done
    105. Creating registry ...
    106. Creating harbor-db ...
    107. Creating harbor-adminserver ...
    108. Creating registry
    109. Creating harbor-db
    110. Creating registry ... done
    111. Creating harbor-ui ...
    112. Creating harbor-ui ... done
    113. Creating nginx ...
    114. Creating harbor-jobservice ...
    115. Creating harbor-jobservice
    116. Creating nginx ... done
    117. ✔ ----Harbor has been installed and started successfully.----
    118. Now you should be able to visit the admin portal at http://192.168.159.68 .
    119. For more details, please visit https://github.com/vmware/harbor .

    5、查看

    1. [root@zwb_docker harbor]# docker-compose ps
    2. Name Command State Ports
    3. ---------------------------------------------------------------------------------------------------------------------------------------------------------
    4. harbor-adminserver /harbor/harbor_adminserver Up
    5. harbor-db docker-entrypoint.sh mysqld Up 3306/tcp
    6. harbor-jobservice /harbor/harbor_jobservice Up
    7. harbor-log /bin/sh -c crond && rm -f ... Up 127.0.0.1:1514->514/tcp
    8. harbor-ui /harbor/harbor_ui Up
    9. nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp,:::443->443/tcp
    10. , 0.0.0.0:4443->4443/tcp,:::4443->44
    11. 43/tcp,
    12. 0.0.0.0:80->80/tcp,:::80->80/tcp
    13. registry /entrypoint.sh serve /etc/ ... Up 5000/tcp

    浏览器访问

     

     之前在docker的daemom.json文件中配置了配置了Harbor的地址,进行删除

    [root@zwb_docker docker]# systemctl daemon-reload                  ## 重新加载守护进程
    [root@zwb_docker docker]# systemctl restart docker.service      ## 重启服务

    在docker.server文件中进行设置:让docker启动时便可指向harbor仓库

    重启服务:

    1. [root@zwb_docker docker]# cd /usr/local/harbor/
    2. [root@zwb_docker harbor]# docker-compose up -d
    3. [root@zwb_docker harbor]# docker ps
    4. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    5. 44d333a47740 vmware/harbor-jobservice:v1.2.2 "/harbor/harbor_jobs…" 4 hours ago Up About a minute harbor-jobservice
    6. 20f31cd89ebd vmware/nginx-photon:1.11.13 "nginx -g 'daemon of…" 4 hours ago Up 27 seconds 0.0.0.0:80->80/tcp, :::80->80/tc443/tcp, :::443->443/tcp, 0.0.0.0:4443->4443/tcp, :::4443->4443/tcp nginx
    7. f5fd0a1aea60 vmware/harbor-ui:v1.2.2 "/harbor/harbor_ui" 4 hours ago Up About a minute harbor-ui
    8. 28358bcc064c vmware/harbor-adminserver:v1.2.2 "/harbor/harbor_admi…" 4 hours ago Up About a minute harbor-adminserver
    9. 863b61ac76c6 vmware/harbor-db:v1.2.2 "docker-entrypoint.s…" 4 hours ago Up About a minute 3306/tcp harbor-db
    10. 2de21a6db7a1 vmware/registry:2.6.2-photon "/entrypoint.sh serv…" 4 hours ago Up About a minute 5000/tcp registry
    11. 26010cca51d2 vmware/harbor-log:v1.2.2 "/bin/sh -c 'crond &…" 4 hours ago Up 49 minutes 127.0.0.1:1514->514/tcp harbor-log

    三、验证 

    1、下载一个小点的镜像,方便实验

    [root@zwb_docker harbor]# docker pull cirros

    1. [root@zwb_docker harbor]# docker pull cirros
    2. Using default tag: latest
    3. latest: Pulling from library/cirros
    4. d0b405be7a32: Pull complete
    5. bd054094a037: Pull complete
    6. c6a00de1ec8a: Pull complete
    7. Digest: sha256:1e695eb2772a2b511ccab70091962d1efb9501fdca804eb1d52d21c0933e7f47
    8. Status: Downloaded newer image for cirros:latest
    9. docker.io/library/cirros:latest

    2、通过命令行登录Harbor

    1. [root@zwb_docker harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1
    2. WARNING! Using --password via the CLI is insecure. Use --password-stdin.
    3. WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
    4. Configure a credential helper to remove this warning. See
    5. https://docs.docker.com/engine/reference/commandline/login/#credentials-store
    6. Login Succeeded ### 登录成功

    3、给需要上传的镜像打tag标记

    1. ## 打tag
    2. [root@zwb_docker harbor]# docker tag cirros:latest 127.0.0.1/public-libary/cirros:v2
    3. [root@zwb_docker harbor]# docker push 127.0.0.1/public-libary/cirros:v2

    4、上传至harbor仓库

    1. [root@zwb_docker harbor]# docker push 127.0.0.1/public-libary/cirros:v2
    2. The push refers to repository [127.0.0.1/public-libary/cirros]
    3. 984ad441ec3d: Layer already exists
    4. f0a496d92efa: Layer already exists
    5. e52d19c3bee2: Layer already exists
    6. v2: digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22 size: 943

    ## 查看仓库上传成功

     删除本地镜像,从仓库下载

    1. [root@zwb_docker harbor]# docker rmi 127.0.0.1/public-libary/cirros:v2
    2. Untagged: 127.0.0.1/public-libary/cirros:v2
    3. Untagged: 127.0.0.1/public-libary/cirros@sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22

     从仓库下载

    1. [root@zwb_docker harbor]# docker pull 192.168.159.68/public-libary/cirros:v2
    2. v2: Pulling from public-libary/cirros
    3. Digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22
    4. Status: Downloaded newer image for 192.168.159.68/public-libary/cirros:v2
    5. 192.168.159.68/public-libary/cirros:v2
    6. [root@zwb_docker harbor]# docker images
    7. REPOSITORY TAG IMAGE ID CREATED SIZE
    8. dockercompose_nginx latest b7d47c45767d 6 hours ago 205MB
    9. a3e7e0eecf4f 6 hours ago 308MB
    10. centos 7 eeb6ee3f44bd 13 months ago 204MB
    11. 192.168.159.68/public-libary/cirros v2 f9cae1daf5f6 19 months ago 12.6MB
    12. cirros latest f9cae1daf5f6 19 months ago 12.6MB
    13. vmware/harbor-log v1.2.2 36ef78ae27df 5 years ago 200MB
    14. vmware/harbor-jobservice v1.2.2 e2af366cba44 5 years ago 164MB
    15. vmware/harbor-ui v1.2.2 39efb472c253 5 years ago 178MB
    16. vmware/harbor-adminserver v1.2.2 c75963ec543f 5 years ago 142MB
    17. vmware/harbor-db v1.2.2 ee7b9fa37c5d 5 years ago 329MB
    18. vmware/nginx-photon 1.11.13 6cc5c831fc7f 5 years ago 144MB
    19. vmware/registry 2.6.2-photon 5d9100e4350e 5 years ago 173MB
    20. vmware/postgresql 9.6.4-photon c562762cbd12 5 years ago 225MB
    21. vmware/clair v2.0.1-photon f04966b4af6c 5 years ago 297MB
    22. vmware/harbor-notary-db mariadb-10.1.10 64ed814665c6 5 years ago 324MB
    23. vmware/notary-photon signer-0.5.0 b1eda7d10640 5 years ago 156MB
    24. vmware/notary-photon server-0.5.0 6e2646682e3c 5 years ago 157MB
    25. photon 1.0 e6e4e4a2ba1b 6 years ago 128MB

     下载完成。如果仓库中没有,会自动到公共仓库下载

  • 相关阅读:
    .net----数据库的访问ADO.NET、DataAdapter和DataSet
    【Spring Boot】响应JSON实现原理
    C++ Reference: Standard C++ Library reference: C Library: cfenv: FE_INVALID
    基于springboot二手交易平台
    音视频封装demo:将h264数据和aac数据封装(mux)成TS文件(纯手工,不依赖第三方开源库)
    SELinux,无semanage,Linux user到SELinux user的映射
    Unity类银河恶魔城学习记录8-5 p81 Blackhole duration源代码
    【深度学习实验】注意力机制(三):打分函数——加性注意力模型
    多态 polymorphism
    【硬件专题】案例:热敏打印效果差?为什么是多个因素造成的?
  • 原文地址:https://blog.csdn.net/m0_62948770/article/details/127460122