AnolisOS7.9安裝Harbor

面向bug编程發表於2024-05-24

1. 確保已安裝好Docker

2. 下載Harbor安裝包

  地址:https://github.com/goharbor/harbor/releases

3. 上傳後解壓

mkdir -p /data/harbor
cd /data/harbor
tar zxvf harbor-offline-installer-v2.9.4.tgz

4. 複製並編輯yml檔案

cd /data/harbor/harbor
cp harbor.yml.tmpl harbor.yml

5. 修改hostname、port、註釋https相關引數

vi /data/harbor/harbor/harbor.yml

6. 安裝

cd /data/harbor/harbor
./install.sh

7. 設定開機啟動

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

 新增如下內容

[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
 
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/libexec/docker/cli-plugins/docker-compose -f /data/harbor/harbor/docker-compose.yml up
ExecStop=/usr/libexec/docker/cli-plugins/docker-compose -f /data/harbor/harbor/docker-compose.yml down
 
[Install]
WantedBy=multi-user.target

8. ExecStart=/usr/local/bin/docker-compose 的路徑透過下面的命令獲取

sudo find / -name docker-compose

8. 使配置生效

systemctl daemon-reload

9. 啟動、重啟、停止、狀態、開機啟動

systemctl start harbor
systemctl restart harbor
systemctl stop harbor
systemctl status harbor
systemctl enable harbor

10. 如果修改了harbor.yml中的配置

cd /data/harbor/harbor
./prepare
docker-compose down -v
docker-compose up -d
# 然後重啟
system restart harbor

# 如果提示bash: docker-compose: 未找到命令...
export PATH=$PATH:/usr/libexec/docker/cli-plugins
# 重新整理
source ~/.bashrc

11. 預設使用者名稱:admin,預設密碼:Harbor12345

相關文章