Docker鏡像私庫Harbor搭建
- 一、擷取Harbor的安裝包
- 三、安裝啟動私服
- 四、啟動和關閉harbor服務
為了友善微服務docker鏡像的管理,在生産環境中基本都需要一個類似于docker.hub的docker鏡像管理私庫。
一、擷取Harbor的安裝包
harbor的Github開源位址:連結
擷取其release版本的安裝包:
在mac環境下選擇如圖的安裝包并下載下傳

二、修改配置檔案
解壓安裝包後,修改harbor.yml配置檔案
因為沒有使用https,是以這裡吧響應的配置注釋掉
# https related config
# 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
修改hostname 和 http對應的port
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: hub.lh0811.com
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 5000
修改預設的harbor賬号admin的密碼
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: 123456
修改資料挂載路徑,為了友善管理 都挂載到目前目錄下,
需要注意的是這裡的路徑需要寫主機目錄的絕對路徑
# The default data volume
data_volume: /Users/lh0811/Desktop/server/harbor/data
# Log configurations
log:
# options are debug, info, warning, error, fatal
level: info
# configs for logs in local storage
local:
# Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
rotate_count: 50
# Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes.
# If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G
# are all valid.
rotate_size: 200M
# The directory on your host that store log
location: /Users/lh0811/Desktop/server/harbor/var/log/harbor
三、安裝啟動私服
使用安裝包中的install腳本
install.sh
需要注意的一點是 harbor目錄中不能有中文
安裝完成後 會在目前目錄下生成一個docker-compose.yaml的描述檔案。
以後就可以使用 docker-compose指令來啟動和關閉harbor服務了
四、啟動和關閉harbor服務
第三步安裝成功後,在harbor的目錄 會有docker-compose.yaml 檔案
啟動harbor服務
docker-compose up -d
關閉harbor服務
docker-compose down
因為有資料挂載是以 隻要挂載資料不被删除 資料都會持久化在本機,每次容器重新開機都會使用挂載資料恢複資料。