---
title: Harbor 架設紀錄
tags: harbor, docker registry
description: Harbor 架設紀錄
---
# Harbor 架設紀錄
內文使用 docker compose 架設 harbor
## Prerequest
環境須先下載好 docker 和 docker-compse
### Build Harbor environment
#### install harbor docker-compose file
```
$ wget https://github.com/goharbor/harbor/releases/download/v2.8.2/harbor-offline-installer-v2.8.2.tgz
$ tar zxvf harbor-offline-installer-v2.8.2.tgz -C /usr/local/
$ cd /usr/local/harbor
$ cp harbor.yml.tmpl harbor.yml
```
#### revise harbor.yml file
`$ sudo nano harbor.yml`
1. 修改 hostname
2. https 修改成以下 http
3. port 修改對 port 號
4. 修改 harbor_admin_password 密碼
```
# Configuration file of Harbor
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.0.25
.
.
.
# https related config
http:
# https port for harbor, default is 443
port: 8081
# The path of cert and key files for nginx
certificate: /your/certificate/path
private_key: /your/private/key/path
...
harbor_admin_password: Harbor12345
```
#### Start building environment
Build結束會有多個harbor container被build起來

```
$ sudo ./install.sh
```
## 別台 Server 推上harbor
在 /etc/docker/daemon.json 內容裡新增如下
```
{"insecure-registries":["192.168.0.25:8081"]}
```
`$ sudo systemctl reload docker`
### Backup
#### 備份靜態檔案
備份一次`/usr/local/harbor/common` 資料夾即可
#### 動態檔案
備份 /data 資料夾底下的folder,包含database,image registry 等等
```
├── data
├── ca_download
├── database
├── job_logs
├── redis
├── registry
├── secret
```
## 參考
* https://blog.51cto.com/lidabai/5168138
* https://stackoverflow.com/questions/49674004/docker-repository-server-gave-http-response-to-https-client
* https://www.blog.lasai.com.tw/2021/06/29/Harbor-%E5%BB%BA%E7%AB%8B%E7%A7%81%E6%9C%89-docker-registry/
* https://www.modb.pro/db/550411
## Thank you! :dash:
You can find me on
- GitHub: https://github.com/shaung08
- Email: a2369875@gmail.com