参考链接

前置准备

harbor 的安装依赖 docker-compose,相关 Issue 《Need to install docker-compose(1.18.0+) by yourself first and run this script again》,为了安装顺利进行,需要额外下载 docker-compose

1
2
3
4
5
6
7
8
9
10
11
12
# 安装 docker compose
sudo apt install docker-compose-plugin

# 查看 docker compose 版本号
docker compose version
>> Docker Compose version v2.10.2

# 根据版本号下载 docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# 为 docker-compose 添加可执行权限
sudo chmod +x /usr/local/bin/docker-compose

下载安装

1
2
3
4
5
6
7
# 下载安装包 https://github.com/goharbor/harbor/releases
wget https://github.com/goharbor/harbor/releases/download/v1.10.14/harbor-online-installer-v1.10.14.tgz

# 解压
tar zxvf harbor-online-installer-v1.10.14.tgz

cd harbor/

编辑配置文件

1
2
3
4
vi harbor.yml

# data_volume -> /data/harbor
# harbor_admin_password -> SOME_RANDOM_STR

标准方式:标准方式需要占用 80 和 443 端口

1
2
3
4
# http.port -> 80
# https.port -> 443
# https.certificate -> /data/acme/fqk.app/fullchain.cer
# https.private_key -> /data/acme/fqk.app/fqk.app.key

Nginx 转发方式

1
2
3
# http.port -> 9080
# external_url -> hub.fqk.app
# https 下的所有配置项

安装及启动

1
sudo ./install.sh

Nginx 转发

hub.fqk.app9080 端口为例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 443 ssl;

ssl_certificate ……;
ssl_certificate_key ……;

server_name hub.fqk.app;

location / {
proxy_read_timeout 300;
proxy_pass http://127.0.0.1:9080;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}

管理员登录

访问 https://hub.fqk.app

1
2
用户名: admin
密码: [harbor.yml 中设置的 harbor_admin_password]

其他命令

1
2
3
4
5
# 停止运行
sudo docker-compose down -v

# 启动
sudo docker-compose up -d