当前位置:   article > 正文

centos7搭建本地harbor仓库_centos7安装harbor

centos7安装harbor

一、Harbor介绍

    Docker容器应用的开发和运行离不开可靠的镜像管理,虽然Docker官方也提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署私有环境内的Registry也是非常必要的。Harbor是由VMware公司开源的企业级的Docker Registry管理项目,它包括权限管理(RBAC)、LDAP、日志审核、管理界面、自我注册、镜像复制和中文支持等功能

二、环境准备 (1台centos7的虚拟机)

        Harbor的所有服务组件都是在Docker中部署的,所以官方安装使用Docker-compose快速部署,所以需要安装Docker、Docker-compose。由于Harbor是基于Docker Registry V2版本,所以就要求Docker-ce版本不小于17.06.0,Docker-compose版本大于等于1.6.0

        1、安装docker-ce 及基础环境

  1. 1:yum install -y yum-utils device-mapper-persistent-data lvm2
  2. 2:yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  3. 3: yum list docker-ce.x86_64 --showduplicates |sort -r
  4. 4: yum install docker-ce-17.09.1.ce -y

       

        2、安装docker-compose        

  1. 1、curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  2. 或者
  3. curl -L https://get.daocloud.io/docker/compose/releases/download/v2.3.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
  4. 2、 chmod +x /usr/local/bin/docker-compose
  5. 3、 docker-compose --version
  6. 4、 docker-compose up

                              

三、安装harbor (下载较慢)

        1、下载harbor离线安装包

  1. 1、wget https://github.com/goharbor/harbor/releases/download/v2.4.2/harbor-offline-installer-v2.4.2.tgz
  2. 2、tar -zxvf harbor-offline-installer-v2.4.2.tgz #解压离线安装包

        2、配置harbor

  1. 1、cd harbor
  2. 2、cp harbor.yml.tmpl harbor.yml
  3. 3、vim harbor.yml
  4. 修改内容:hostname = 10.130.77.28 #修改harbor的启动ip为你虚拟机的ip
  5. harbor_admin_password = admin@123 #修改harbor的admin用户的密码

         3、启动harbor  

 bash install.sh

         4、docker-compose ps 查看

 四、访问harbor(我这里是http://192.168.68.137/)   

1、新建个项目目录

  2、命令行登陆harbor ( )

 注意:第一次登录一般都会报错 

Error response from daemon: Get "https://192.168.68.137/v2/": dial tcp 10.130.77.48:443: connect: no route to host
  1. [root@node-3 ~]# vim /usr/lib/systemd/system/docker.service
  2. ExecStart=/usr/bin/dockerd --insecure-registry 192.168.68.137
  3. 修改配置文件,ExecStart之后添加
  4. 重启docker
  5. systemctl daemon-reload
  6. systemctl restart docker

 3、测试上传镜像到harbor

        

  1. root@host_137 ~]# docker pull nginx
  2. Using default tag: latest
  3. latest: Pulling from library/nginx
  4. 3f4ca61aafcd: Pull complete
  5. 50c68654b16f: Pull complete
  6. 3ed295c083ec: Pull complete
  7. 40b838968eea: Pull complete
  8. 88d3ab68332d: Pull complete
  9. 5f63362a3fa3: Pull complete
  10. Digest: sha256:0047b729188a15da49380d9506d65959cce6d40291ccfb4e039f5dc7efd33286
  11. Status: Downloaded newer image for nginx:latest
  12. [root@host_137 ~]# docker docker tag nginx:latest 192.168.68.137/harbor/nginx:latest
  13. docker: 'docker' is not a docker command.
  14. See 'docker --help'
  15. [root@host_137 ~]# docker images
  16. REPOSITORY TAG IMAGE ID CREATED SIZE
  17. nginx latest 1403e55ab369 5 days ago 142MB
  18. goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
  19. goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
  20. goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
  21. goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
  22. goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
  23. goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
  24. goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
  25. goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
  26. goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
  27. goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
  28. goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
  29. goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
  30. goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
  31. goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
  32. goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
  33. [root@host_137 ~]# docker tag nginx:latest 192.168.68.137/harbor/nginx:latest
  34. [root@host_137 ~]# docker images
  35. REPOSITORY TAG IMAGE ID CREATED SIZE
  36. 192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
  37. nginx latest 1403e55ab369 5 days ago 142MB
  38. goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
  39. goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
  40. goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
  41. goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
  42. goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
  43. goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
  44. goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
  45. goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
  46. goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
  47. goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
  48. goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
  49. goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
  50. goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
  51. goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
  52. goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
  53. [root@host_137 ~]# docker push 192.168.68.137/harbor/nginx
  54. The push refers to a repository [192.168.68.137/harbor/nginx]
  55. c72d75f45e5b: Layer already exists
  56. 9a0ef04f57f5: Layer already exists
  57. d13aea24d2cb: Layer already exists
  58. 2b3eec357807: Layer already exists
  59. 2dadbc36c170: Layer already exists
  60. 8a70d251b653: Layer already exists
  61. latest: digest: sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c size: 1570
  62. [root@host_137 ~]#

查看镜像仓库 

测试拉取镜像 (先将本地的镜像删除)

  1. [root@host_137 ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. nginx latest 1403e55ab369 5 days ago 142MB
  4. 192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
  5. goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
  6. goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
  7. goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
  8. goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
  9. goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
  10. goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
  11. goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
  12. goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
  13. goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
  14. goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
  15. goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
  16. goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
  17. goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
  18. goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
  19. goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
  20. [root@host_137 ~]# docker rmi 192.168.68.137/harbor/nginx
  21. Untagged: 192.168.68.137/harbor/nginx:latest
  22. Untagged: 192.168.68.137/harbor/nginx@sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c
  23. [root@host_137 ~]# docker images
  24. REPOSITORY TAG IMAGE ID CREATED SIZE
  25. nginx latest 1403e55ab369 5 days ago 142MB
  26. goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
  27. goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
  28. goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
  29. goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
  30. goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
  31. goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
  32. goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
  33. goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
  34. goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
  35. goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
  36. goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
  37. goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
  38. goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
  39. goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
  40. goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
  41. [root@host_137 ~]# docker pull 192.168.68.137/harbor/nginx
  42. Using default tag: latest
  43. latest: Pulling from harbor/nginx
  44. Digest: sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c
  45. Status: Downloaded newer image for 192.168.68.137/harbor/nginx:latest
  46. [root@host_137 ~]# docker images
  47. REPOSITORY TAG IMAGE ID CREATED SIZE
  48. nginx latest 1403e55ab369 5 days ago 142MB
  49. 192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
  50. goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
  51. goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
  52. goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
  53. goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
  54. goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
  55. goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
  56. goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
  57. goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
  58. goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
  59. goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
  60. goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
  61. goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
  62. goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
  63. goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
  64. goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
  65. [root@host_137 ~]#

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/913141
推荐阅读
相关标签
  

闽ICP备14008679号