Docker Harbor 安裝教程

1. Harbor簡介

Harbor簡介
Harbor is an open source container image registry that secures images with role-based access control, scans images for vulnerabilities, and signs images as trusted. A CNCF Incubating project, Harbor delivers compliance, performance, and interoperability to help you consistently and securely manage images across cloud native compute platforms like Kubernetes and Docker.
Harbor是一個開源容器鏡像註冊表,它通過基於角色的訪問控制保護鏡像,掃描鏡像漏洞,並將鏡像標記爲可信鏡像。作爲CNCF的孵化項目,Harbor提供了遵從、性能和互操作性去幫助你一致而又安全的管理鏡像通過像Kubernetes 和Docker這樣的雲計算平臺。

官網:https://goharbor.io/
下載地址:https://github.com/goharbor/harbor/releases

2. 服務端安裝

  • Root用戶安裝
  • 已安裝Docker
  • 已安裝docker-compose
  • 內網安裝建議使用域名,默認端口80,本文以myrepo.example.com
  • 外網安裝如果能申請域名使用域名,不能的話就ip+端口號,比如10.10.10.235:8888

2.1 下載安裝包

wget https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-online-installer-v1.9.0.tgz

1.2 解壓

tar zxvf  harbor-online-installer-v1.9.0.tgz

1.3 修改配置文件

  • 修改harbor配置文件
vi harbor.yml

如下圖:
在這裏插入圖片描述

  • 修改hosts文件
 vi /etc/hosts

如下圖:
在這裏插入圖片描述

1.4 啓動harbor

  • 環境檢查
./prepare
  • 安裝並啓動
./install.sh

1.5 登錄harbor

  • 訪問myrepo.example.com
  • 新建項目:hyperledger,訪問級別:公開
    在這裏插入圖片描述
  • 創建用戶:

在這裏插入圖片描述

  • 給項目添加成員:

在這裏插入圖片描述

2. 客戶端使用

  • root用戶登錄或者sudo用戶
  • 已安裝Docker
  • 已安裝docker-compose
  • docker默認支持https

2.1 支持http

2.1.1 查看docker.service位置

  • root用戶登錄或者sudo用戶
systemctl status docker 

在這裏插入圖片描述

2.1.2 修改docker.service

vi /usr/lib/systemd/system/docker.service

在ExecStart這一行後面增加內容:

--insecure-registry=myrepo.example.com

在這裏插入圖片描述

2.1.3 修改daemon.json

vi /etc/docker/daemon.json

添加私有倉庫地址:

http://myrepo.example.com

如下圖:
在這裏插入圖片描述

2.1.4 修改hosts

vi /etc/hosts

添加內容:

192.168.134.150 myrepo.example.com

如下圖:
在這裏插入圖片描述

2.2 重啓docker

systemctl daemon-reload
systemctl restart docker

2.3 鏡像上傳下拉

  • 應用用戶
  • 按指定格式打tag
docker tag hyperledger/fabric-ca:latest myrepo.example.com/hyperledger/fabric-ca-test:1.4.1
  • 登錄harbor
docker login myrepo.example.com
  • Push鏡像
docker push myrepo.example.com/hyperledger/fabric-ca-test:1.4.1
  • Pull鏡像
    公共倉庫的鏡像無需登錄即可直接pull
 docker pull hyperledger/fabric-ca-test:1.4.1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章