日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Harbor鏡像倉庫搭建

作者:吉松松 更新時間: 2022-07-09 編程語言

Harbor鏡像倉庫搭建

1、安裝底層需求

  • ? Python應該是2.7或更高版本
  • ? Docker引擎應為1.10或更高版本
  • ? DockerCompose需要為1.6.0或更高版本

2、Harbor安裝

Harbor 官方地址:

? https://github.com/vmware/harbor/releases

配置harbor.yml

$ tar -zxvf harbor-online-installer-v2.5.2.tgz  #采用在線安裝
$ cd harbor && vim harbor.yml
...
hostname: harbor.registry.com  #目標的主機名或者完全限定域名
http:                          #默認http協議,如果https能用,可自動跳轉https
  port: 80                     #對外訪問端口

#https:                        #https需要證書可先注釋
#  port: 443                    
#  certificate: /your/certificate/path   #證書存放路徑
#  private_key: /your/private/key/path   #私鑰存放路徑
...
harbor_admin_password: Harbor12345  #登錄harbor默認密碼
database:
  password: root123  #數據庫默認連接密碼
....
data_volume: /data   #設置Harbor的數據存放目錄
...
log:                 #設置日志相關信息
  level: info        #設置日志級別
  local:
    rotate_count: 50   #日志保留個數
    rotate_size: 200M  #每個日志大小
    location: /var/log/harbor  #日志存放路徑
    
$  ./install.sh
[Step 4]: starting Harbor ...
.....
? ----Harbor has been installed and started successfully.----  #表示搭建成功

使用命令行登陸Harbor,并上傳鏡像和下載鏡像

由于docker拉取鏡像默認是https協議,我們需要在/etc/docker/daemon.json中配置insecure-registries.
{"insecure-registries": ["harbor.registry.com"] }

$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
170.18.9.141 harbor.registry.com

$ systemctl restart docker

$ docker login harbor.registry.com   #登錄倉庫,認證信息保留在/家目錄下/.docker/config.json文件中
Username: admin
Password: 
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
#給鏡像打上符合倉庫的標簽鏡像
$ docker tag nginx:latest harbor.registry.com/library/nginx:v1 
#推送鏡像
$ docker push harbor.registry.com/library/nginx:v1
The push refers to repository [harbor.registry.com/library/nginx]
e7344f8a29a3: Pushed 
44193d3f4ea2: Pushed 
41451f050aa8: Pushed 
b2f82de68e0d: Pushed 
d5b40e80384b: Pushed 
08249ce7456a: Pushed 
v1: digest: sha256:3536d368b898eef291fb1f6d184a95f8bc1a6f863c48457395aab859fda354d1 size: 1570

配置Harbor的HTTPS訪問

參考棧內文章自制https證書,生成證書后,放入harbor.yml配置文件的中certificate,private_key參數對應的路徑下即可。

原文鏈接:https://blog.csdn.net/m0_37642477/article/details/125590884

欄目分類
最近更新