Harbor 升级(Docker Compose 部署方式)

记录 Docker Compose 部署的 Harbor 从 v2.11.2 升级至 v2.13.1。

参考文档:https://goharbor.io/docs/2.13.0/administration/upgrade/

升级步骤

停止现有 Harbor 实例:

1
2
cd harbor
docker-compose down

备份现有 Harbor 配置文件:

1
2
mkdir -pv ~/harbor_backup/v2.11.2
mv harbor ~/harbor_backup/v2.11.2

备份 DB:

1
cp -r /data/database ~/harbor_backup/v2.11.2

下载最新版本安装包:

1
wget "https://github.com/goharbor/harbor/releases/download/v2.13.1/harbor-offline-installer-v2.13.1.tgz"

获取镜像:

1
2
tar zxf harbor-offline-installer-v2.13.1.tgz
docker load -i harbor/harbor.v2.13.1.tar.gz

拷贝旧版本配置文件,通过 goharbor/prepare 镜像进行升级:

1
2
cp harbor_backup/v2.11.2/harbor/harbor.yml ~/
docker run -it --rm -v /:/hostfs goharbor/prepare:v2.13.1 migrate -i ~/harbor.yml

执行成功后日志如下:

1
2
3
4
root@172-16-16-14-harbor:~# docker run -it --rm -v /:/hostfs goharbor/prepare:v2.13.1 migrate -i ~/harbor.yml
migrating to version 2.12.0
migrating to version 2.13.0
Written new values to /root/harbor.yml

harbor.yml 移至新版本安装目录中:

1
mv harbor.yml harbor

执行安装:

1
./install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
root@172-16-16-14-harbor:~/harbor# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 27.3.1

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.29.7

[Step 2]: loading Harbor images ...
Loaded image: goharbor/nginx-photon:v2.13.1
Loaded image: goharbor/registry-photon:v2.13.1
Loaded image: goharbor/trivy-adapter-photon:v2.13.1
Loaded image: goharbor/harbor-db:v2.13.1
Loaded image: goharbor/harbor-registryctl:v2.13.1
Loaded image: goharbor/harbor-exporter:v2.13.1
Loaded image: goharbor/redis-photon:v2.13.1
Loaded image: goharbor/harbor-jobservice:v2.13.1
Loaded image: goharbor/prepare:v2.13.1
Loaded image: goharbor/harbor-portal:v2.13.1
Loaded image: goharbor/harbor-core:v2.13.1
Loaded image: goharbor/harbor-log:v2.13.1


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
copy /data/secret/tls/harbor_internal_ca.crt to shared trust ca dir as name harbor_internal_ca.crt ...
ca file /hostfs/data/secret/tls/harbor_internal_ca.crt is not exist
copy to shared trust ca dir as name storage_ca_bundle.crt ...
copy None to shared trust ca dir as name redis_tls_ca.crt ...
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Running 10/10
✔ Network harbor_harbor Created 0.3s
✔ Container harbor-log Started 1.0s
✔ Container registry Started 1.9s
✔ Container redis Started 1.7s
✔ Container harbor-portal Started 1.8s
✔ Container harbor-db Started 1.7s
✔ Container registryctl Started 1.8s
✔ Container harbor-core Started 2.5s
✔ Container nginx Started 3.4s
✔ Container harbor-jobservice Started 2.9s
✔ ----Harbor has been installed and started successfully.----
Author

Warner Chen

Posted on

2025-07-07

Updated on

2025-07-07

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.