下载
基于 Docker 部署
安装 Docker
- 安装 Docker
- 已包含
docker compose,命令是 docker compose 而不是 docker-compose
安装 Harbor
解压 harbor-offline-installer-vx.y.z.tgz
- 解压后的内容
harbor.vx.y.z.tar.gz:docker 离线安装的镜像
harbor.yml.tmpl:配置文件模板
install.sh:安装脚本,会自动将离线安装镜像 harbor.vx.y.z.tar.gz 导入到 Docker 内
prepare:检查配置文件、Docker 镜像
# yum -y install tar
tar -zxvf harbor-offline-installer-v2.12.2.tgz
进入到 harbor 目录
cd harbor
创建配置文件 harbor.yml
# create harbor.yml
cp harbor.yml.tmpl harbor.yml
# 不存在 harbor.yml 执行 ./prepare 异常
[root@anolis-8-9 harbor]# ./prepare
prepare base dir is set to /root/harbor
no config file: /root/harbor/harbor.yml
[root@anolis-8-9 harbor]#
# 不存在 harbor.yml 执行 ./install.sh 异常
[root@anolis-8-9 harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 26.1.3
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.27.0
[Step 2]: loading Harbor images ...
......
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
no config file: /root/harbor/harbor.yml
[root@anolis-8-9 harbor]#
修改 hostname
# yum -y install vim
vim harbor.yml
# hostname 配置
# 修改为自己要使用的域名
hostname: harbor.xuxiaowei.com.cn
# 不修改 hostname 执行 ./prepare 异常
[root@anolis-8-9 harbor]# ./prepare
prepare base dir is set to /root/harbor
ERROR:root:Please specify hostname
Error happened in config validation...
[root@anolis-8-9 harbor]#
# 不修改 hostname 执行 ./install.sh 异常
[root@anolis-8-9 harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 26.1.3
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.27.0
[Step 2]: loading Harbor images ...
......
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
ERROR:root:Please specify hostname
Error happened in config validation...
[root@anolis-8-9 harbor]#
增加 https 证书配置
vim 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
# 使用 Nginx 证书
# 需要使用绝对位置
certificate: /root/harbor/xuxiaowei.com.cn.crt
private_key: /root/harbor/xuxiaowei.com.cn.key
# 不修改 https 证书配置 执行 ./prepare 异常
[root@anolis-8-9 harbor]# ./prepare
prepare base dir is set to /root/harbor
Error happened in config validation...
ERROR:root:Error: The protocol is https but attribute ssl_cert is not set
[root@anolis-8-9 harbor]#
# 不修改 https 证书配置 执行 ./install.sh 异常
[root@anolis-8-9 harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 26.1.3
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.27.0
[Step 2]: loading Harbor images ...
......
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
Error happened in config validation...
ERROR:root:Error: The protocol is https but attribute ssl_cert is not set
[root@anolis-8-9 harbor]#
安装成功日志
[root@anolis-8-9 harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 26.1.3
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.27.0
[Step 2]: loading Harbor images ...
Loaded image: goharbor/redis-photon:v2.12.2
Loaded image: goharbor/nginx-photon:v2.12.2
Loaded image: goharbor/registry-photon:v2.12.2
Loaded image: goharbor/prepare:v2.12.2
Loaded image: goharbor/harbor-portal:v2.12.2
Loaded image: goharbor/harbor-core:v2.12.2
Loaded image: goharbor/harbor-jobservice:v2.12.2
Loaded image: goharbor/harbor-registryctl:v2.12.2
Loaded image: goharbor/harbor-log:v2.12.2
Loaded image: goharbor/harbor-db:v2.12.2
Loaded image: goharbor/harbor-exporter:v2.12.2
Loaded image: goharbor/trivy-adapter-photon:v2.12.2
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /root/harbor
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
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
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.2s
✔ Container harbor-log Started 0.3s
✔ Container harbor-db Started 0.6s
✔ Container harbor-portal Started 0.6s
✔ Container registry Started 0.7s
✔ Container registryctl Started 0.6s
✔ Container redis Started 0.6s
✔ Container harbor-core Started 0.8s
✔ Container nginx Started 1.1s
✔ Container harbor-jobservice Started 1.1s
✔ ----Harbor has been installed and started successfully.----
[root@anolis-8-9 harbor]#
安装成功的容器
[root@anolis-8-9 harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0de3b3f0c7e7 goharbor/harbor-jobservice:v2.12.2 "/harbor/entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-jobservice
0ef0ed812a38 goharbor/nginx-photon:v2.12.2 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp nginx
a436cdb7ea64 goharbor/harbor-core:v2.12.2 "/harbor/entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-core
d43cab5ce204 goharbor/harbor-registryctl:v2.12.2 "/home/harbor/start.…" 2 minutes ago Up 2 minutes (healthy) registryctl
6fcfebdfe3e8 goharbor/registry-photon:v2.12.2 "/home/harbor/entryp…" 2 minutes ago Up 2 minutes (healthy) registry
cb577c77a88a goharbor/redis-photon:v2.12.2 "redis-server /etc/r…" 2 minutes ago Up 2 minutes (healthy) redis
76565dae7d8b goharbor/harbor-db:v2.12.2 "/docker-entrypoint.…" 2 minutes ago Up 2 minutes (healthy) harbor-db
04e1d3ffc305 goharbor/harbor-portal:v2.12.2 "nginx -g 'daemon of…" 2 minutes ago Up 2 minutes (healthy) harbor-portal
c9cf9a746666 goharbor/harbor-log:v2.12.2 "/bin/sh -c /usr/loc…" 2 minutes ago Up 2 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
[root@anolis-8-9 harbor]#
登录
- 用户名:
admin
- 密码:
Harbor12345
- 在配置文件
harbor.yml 中 harbor_admin_password 可以修改默认密码