Harbor下载
Harbor项目地址:https://github.com/goharbor/harbor/releases
wget https://github.com/goharbor/harbor/releases/download/v2.11.2/harbor-offline-installer-v2.11.2.tgz
配置Harbor
#解压
tar -zxvf harbor-offline-installer-v2.11.2.tgz
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
hostname:harbor.kubiyun.com
#配置启动端口号
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port:80
# ssl证书和端口配置,根据需求,如果使用http,就不配置该段
https:
# https port for harbor, default is 443
port: 8443
# The path of cert and key files for nginx
certificate: /etc/ssl/harbor/harbor.kubiyun.com_bundle.crt
private_key: /etc/ssl/harbor/harbor.kubiyun.com.key
#启动成功后,admin用户登录密码
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password:Kby123456
防火墙管理
#安装ufw防火墙并开启端口
apt-get install -y ufw
ufw allow 8443 #开启端口
ufw allow 80
ufw status #查看开启了那些端口
ufw delete allow 9980 #删除端口规则
ufw enable #开机自启动
启动运行
cd /home/ harbor-offline-installer-v2.11.2
./install.sh


Harbor使用指南
这里以新建公开项目为例进行说明:项目–>新建项目–>填写相关信息,访问级别勾选:公开说明:当访问级别设置为公开后,任何人都有此项目下镜像的读权限,命令行用户都不需要docker login就可以拉取此项目下的镜像。
点击镜像仓库右上角显示推送命令,可以通过提示命令进行docker镜像的推送
私有仓库的使用
登录私有仓库
docker login -u admin -p Kby123456 https://harbor.kubiyun.com:8443
本地已打包好的镜像打标签,推送到harbor仓库
docker tag collabora/code:24.04.10.1.1 harbor.kubiyun.com:8443/test-project/collabora:latest
推送
docker push harbor.kubiyun.com:8443/test_project/collabora:latest
#拉取镜像
docker pull harbor.kubiyun.com:8443/test_project/nginx:1.26.0
将harbor配置为docker镜像源
vi /etc/docker/daemon.json
{
“registry-mirrors”:[“https://harbor.kubiyun.com:8443/test_project”]
}
#重启docker
systemctl restart docker.service
#查看是否修改成功
docker info
原创文章,作者:jacky,如若转载,请注明出处:https://kubiyun.com/archives/302