docker私库harbor安装配置

本文章仅作为个人笔记

harbor 使用 参考

  • 安装

    • docker-compose下载页面

      wget https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64
      mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
      chmod +x /usr/local/bin/docker-compose
      
    • harbor下载页面

      # 生成密钥(非必须,若不需要支持https可不生成)
      cd /home
      mkdir harbor-keys
      cd harbor-keys
      openssl genrsa -out rsa_private.key 2048
      # 这一步需要填一些东西,记得别填密码,另外 Common Name 填域名或者host里对应当前ip的值(如:master)
      openssl req -new -key rsa_private.key -out rsa_private.csr
      openssl x509 -req -days 365 -in rsa_private.csr -signkey rsa_private.key -out rsa_private.crt
      cd ..
      # 此处为正式安装,若无需https支持可注释对应配置
      wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz
      tar xvf harbor-offline-installer-v2.0.2.tgz
      cp ./harbor/harbor.yml.tmpl ./harbor/harbor.yml
      vim ./harbor/harbor.yml
          hostname: <host_ip>
          https:
            port: 443
            certificate: /home/harbor-keys/rsa_private.crt
            private_key: /home/harbor-keys/rsa_private.key
      yum install -y yum-utils
      yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
      dnf install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
      yum install docker-ce -y
      service docker restart
      ./harbor/install.sh
      # 安装完 访问 http://<host_ip> 即可查看harbor
      # 默认用户名密码在配置文件内,为 admin Harbor12345 可自行修改
      # docker更改配置
      vim  /etc/docekr/daemon.json
      	
      	{
              "registry-mirrors": [
                  "https://<host_ip>:<host_port>"
              ],
              "insecure-registries": [
                  "https://<host_ip>:<host_port>"
              ]
      	}
      
      systemctl daemon-reload
      service docker restart
      # 在gui界面新建项目 (例: demo_pro)
      # 制作镜像 (例:docker tag mongo 192.168.9.128/demo_pro/demo_mongo:0.0.1)(需先 docker pull mongo)
      docker tag <image_name> <host_ip>/<private_image_package>/<private_image_name>:<private_image_version>
      
  • 上传制作的镜像至harbor (例:docker push 192.168.9.128/demo_pro/demo_mongo:0.0.1)

    docker login <host_ip>
    docker push <host_ip>/<private_image_package>/<private_image_name>:<private_image_version>
    
  • 再访问 http://<host_ip> 即可看到新上传的镜像了

  • 服务操作:(于/harbor 目录运行)

    docker-compose stop
    docker-compose start
    
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页