安装

下载文件
https://github.com/goharbor/harbor/releases

  1. tar -zxvf harbor-offline-installer-v2.3.4.tgz

修改cfg文件:

cp harbor.yml.tmpl harbor.yml
vim harbor.yml

修改harbor.yml
https://goharbor.io/docs/2.4.0/install-config/configure-yml-file/

hostname=192.168.101.10
// 修改密码
harbor_admin_password: Harbor12345
// 如果不用https注释
https、certificate、private_key

创建存储路径

mkdir /data

初始化,完成安装

./prepare
sh install.sh

登录

192.168.101.10,用户名默认admin,密码是上面配置的
使用docker登录

docker login 192.168.101.10

登录失败:

vi /etc/docker/daemon.json
{
  "registry-mirrors": ["地址"],
  "insecure-registries":["192.168.101.10"] // 不要端口
}


systemctl daemon-reload && systemctl restart docker
// harbor重启
docker-compose start

使用

新建项目
image.png
image.png
标记并推送,与推送到私有仓库相同

docker tag centos:latest 192.168.101.10/test/centos:1.6.0
docker push 192.168.101.10/test/centos:1.6.0

拉取(注意改成image:tag的形式,不然删除很麻烦):
image.png

常用命令

重启

使用systemctlrestartdocker重启docker之后需要重启harbor

使用docker-compose命令,需要进入对应的文件夹且文件夹中有docker-compose.yml文件

cd /opt/harbor  // 这个文件夹中有docker-compose.yml文件
docker-compose stop
docker-compose start
docker-compose restart

引用

https://www.bilibili.com/video/BV1h5411P7Nm?p=9