說明:
??該流程用于記述Linux服務器下使用docker鏡像安裝harbor,配置自有docker鏡像庫。
??其中Linux環(huán)境全部基于docker容器鏡像進行配置與安裝。
??涉及harbor的權限和賬戶、項目設置操作。
??涉及docker對harbor的信任、登陸、登出、上傳、拉取操作。
環(huán)境準備:
Linux系統(tǒng):
??harbor服務器 使用阿里云服務器【harbor-offline-installer-v2.11.1.tgz】
??下載地址:https://github.com/goharbor/harbor/releases/download/v2.10.0/harbor-offline-installer-v2.11.1.tgz
注:服務器搭建配置不在本次內(nèi)容中,后續(xù)會補充配置記錄連接
Windows端操作
01、獲取安裝包
訪問下載地址,獲取到安裝包文件
也可以使用Linux命令下載
wget https://github.com/goharbor/harbor/releases/download/v2.10.0/harbor-offline-installer-v2.10.0.tgz
02、上傳壓縮包至/opt

03、創(chuàng)建存放目錄,執(zhí)行解壓操作
mkdir -p /apps
tar zxf /opt/harbor-offline-installer-v2.11.1.tgz -C /apps/
04、進入目錄,復制啟動配置文件
注:若無yml.tmp文件,可以手動創(chuàng)建或復制一份yml文件
cd /apps/harbor
cp harbor.yml.tmpl harbor.yml
05、編輯啟動文件
vim harbor.yml
# 修改hostname的值,如果沒有域名就使用本機IP地址
# 不可使用localhost或者172.0.0.1
hostname: 192.168.192.10
# 配置啟動端口號
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
# 此處任意,不沖突即可
port: 5000
# 如果沒有申請證書,需要隱藏https
# 需要注釋端口號、cert和key路徑配置
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
# 啟動成功后,admin用戶登錄密碼,默認密碼是AdminHarbor12345
# harbor對密碼的要求是8位或以上,需含大小寫字母,可帶數(shù)字
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: AdminHarbor12345
06、啟動初始化配置安裝
注:需要網(wǎng)絡正常,會拉取必要的docker鏡像
./install.sh
07、系統(tǒng)正常安裝完成后,可以登陸訪問harbor項目

08、頁面功能介紹與常用功能說明






Linux端操作
09、添加信任,更新配置,并重新加載配置文件與重啟docker
# 編輯daemon.json配置文件
vim /etc/docker/daemon.json
# 增加如下配置
"insecure-registries": [
"harbor-ip:harbor-prot"
]
# 重新加載配置文件
systemctl daemon-reload
# 重啟docker
systemctl restart docker
# 查看狀態(tài)
systemctl status docker
10、登陸/登出服務
# 登入
docker login -u test -p testDocker123 ip:prot
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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 logout ip:prot
Removing login credentials for ip:prot
11、本地鏡像打tag標簽,上傳harbor,從harbor拉取
# 格式說明
# docker push ip:prot/項目名稱/鏡像名稱:版本號
docker push ip:prot/yjs-dockers/REPOSITORY[:TAG]
# 舉例
docker tag nginx:1.27.2 ip:prot/yjs-dockers/nginx:1.27.2
docker tag jenkins/jenkins:2.484 ip:prot/yjs-dockers/jenkins/jenkins:2.484
# 上傳
docker push ip:prot/yjs-dockers/mysql:5.7
The push refers to repository [ip:prot/yjs-dockers/mysql]
441e16cac4fe: Pushed
73cb62467b8f: Pushed
337ec6bae222: Pushed
532b66f4569d: Pushed
0d9e9a9ce9e4: Pushed
4555572a6bb2: Pushed
8527ccd6bd85: Pushed
d76a5f910f6b: Pushed
8b2952eb02aa: Pushed
7ff7abf4911b: Pushed
cff044e18624: Pushed
5.7: digest: sha256:4b6c4935195233bc10b617df3cc725a9ddd5a7f10351a7bf573bea0b5ded7649 size: 2618
12、 查看上傳鏡像


魔法有坑需要注意
在前面配置魔法的時候,新建了一個/etc/systemd/system/docker.service.d/proxy.conf配置文件
其中在無需代理的ip,要將harbor的ip加進去
[Service]
Environment="HTTP_PROXY=192.168.70.1:10811/"
Environment="HTTPS_PROXY=192.168.70.1:10811/"
Environment="NO_PROXY=localhost,127.0.0.1,harbor-ip"
本文來自博客園,作者:YamaNogi,轉載請注明原文鏈接:http://www.rzrgm.cn/yamanogi-bky/articles/18547559
浙公網(wǎng)安備 33010602011771號