1.前置依赖
需要:DockerCompose
2.安装
a.在线安装
### 下载安装文件
```shell
wget "https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz"
```
### 解压文件
```shell
tar -xvf harbor-offline-installer-v2.6.0.tgz
```
### 配置harbor.yml
```bash
# 设置对外访问的域名
hostname: dockerhub.ai.local
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 88
# https related config
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
#certificate: /your/certificate/path
#private_key: /your/private/key/path
harbor_admin_password: Harbor12345
# Harbor DB configuration
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 50
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 1024 for postgres of harbor.
max_open_conns: 1000
# The default data volume,⚠️需要修改,设置数据的存储目录
data_volume: /export/harbor/data
......
# The directory on your host that store log ,⚠️需要修改,设置日志的存储目录
location: /export/harbor/log
```
### 安装harbor
```bash
./install.sh
```
### 查看harbor安装情况
```shell
docker-compose ps
```
b.离线安装
待补充
3.停止服务
```shell
docker-compose down
```
4.常用配置
修改配置:harbor.yml
使配置生效
```shell
# 停止服务
docker-compose down
# 再次启动服务使配置生效
./install.sh
```
5.配置对外访问[非必须]
使用Nginx作为访问出口,配置如下
dockerhub-harbor.conf
```shell
upstream dockerhub-service {
server xx.xx.xx.xx:88;
}
server {
listen 80;
listen 443 ssl ; # 不可少,docker默认走这个端口,没有此配置会匹配到其他server
server_name dockerhub.ai.local;
location / {
#需要代理的地址
proxy_pass http://dockerhub-service;
}
access_log /usr/local/nginx/logs/dockerhub-access.log;
error_log /usr/local/nginx/logs/dockerhub-error.log;
}
```
6.登陆
登陆地址:http://dockerhub.ai.local/
登陆账号:admin / Harbor12345