Harbor /ˈhɑrbər/ 是一个开源 registry,它使用策略和基于角色的访问控制来保护工件,确保 images 被扫描并且没有漏洞,并将 images 标记为可信。Harbor 是一个 CNCF 毕业项目,它提供合规性、性能和互操作性,以帮助您跨云原生计算平台(如 Kubernetes 和 Docker)持续、安全地管理工件。
An open source trusted cloud native registry project that stores, signs, and scans content.
下载安装
1
2
3
4
5
6
7
8
9
10
11
|
sudo mkdir /opt/harbor && sudo chown ynthm /opt/harbor && cd /opt/harbor
wget https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz
x harbor-offline-installer-v2.5.0.tgz
ln -s harbor app
echo "127.0.0.1 harbor.ynthm.com" | sudo tee -a /etc/hosts
# 注意,tee 命令的 "-a" 选项的作用等同于 ">>" 命令,如果去除该选项,那么 tee 命令的作用就等同于 ">" 命令。
cd app
cp harbor.yml.tmpl harbor.yml
code harbor.yml
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
hostname: harbor.ynthm.com
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# https related config
https:
# https port for harbor, default is 443
port: 443
# The path of cert and key files for nginx
certificate: /opt/cert/ynthm.com/fullchain.cert.pem
private_key: /opt/cert/ynthm.com/ynthm.com.key.pem
data_volume: /opt/harbor/data
log:
# The directory on your host that store log
location: /opt/harbor/log
|
1
2
3
4
5
6
7
|
# 下载测试镜像
docker pull hello-world
# 给镜像重新打标签
docker tag hello-world harbor.ynthm.com/hello-world:latest
# 登录进行上传
docker login harbor.ynthm.com
docker push harbor.ynthm.com/hello-world:latest
|
停止和启动
我们之前执行 install.sh 的时候自动将 harbor 拉起来了,总不能每次重启都执行 install.sh 对吧。
它的停止和启动的方式如下:
1
2
|
docker-compose stop
docker-compose start
|
如果你想要改变 harbor 配置,你应该使用上面的命令先停止 harbor,然后修改 harbor.yml,执行 prepare 生成新的配置,然后启动 harbor。整个过程如下:
1
2
3
4
|
docker-compose down -v
vim harbor.yml
./prepare
docker-compose up -d
|