安装Harbor镜像仓库

简介: 本文介绍了如何在Linux系统上安装和配置Harbor镜像仓库。首先通过阿里云镜像源安装Docker,然后下载并解压Harbor离线安装包。配置Harbor服务的相关参数。最后,通过运行安装脚本完成Harbor的安装,并进行基本的测试,包括登录、构建和推送Docker镜像。文章还提供了相关资源链接,方便读者进一步了解和学习。

安装Harbor镜像仓库

安装docker

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

下载harbor安装包

# 下载Docker Harbor安装包
wget https://github.com/goharbor/harbor/releases/download/v2.12.0/harbor-offline-installer-v2.12.0.tgz

# 解压安装包
[root@chenby ~]# tar xvf harbor-offline-installer-v2.12.0.tgz  -C /usr/local/
harbor/harbor.v2.12.0.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl
[root@chenby ~]# cd /usr/local/harbor/

创建证书

# 我用的是免费证书  Let's Encrypt 泛域名证书申请
https://www.oiox.cn/index.php/archives/139/

配置harbor服务

# 配置harbor文件
[root@chenby harbor]# cp harbor.yml.tmpl harbor.yml
[root@chenby harbor]# vim harbor.yml 
[root@chenby harbor]# cat harbor.yml | grep -v '^#' | grep -v '^$' | grep -v '  #'
hostname: z.oiox.cn 
http:
  port: 18081
https:
  port: 18082
  certificate: /ssl/cert.pem
  private_key: /ssl/cert.key
harbor_admin_password: Cby123.. 
database:
  password: root123
  max_idle_conns: 100
  max_open_conns: 900
  conn_max_lifetime: 5m
  conn_max_idle_time: 0
data_volume: /data
trivy:
  ignore_unfixed: false
  skip_update: false
  skip_java_db_update: false
  offline_scan: false
  security_check: vuln
  insecure: false
  timeout: 5m0s
jobservice:
  max_job_workers: 10
  job_loggers:
    - STD_OUTPUT
    - FILE
  logger_sweeper_duration: 1 #days
notification:
  webhook_job_max_retry: 3
  webhook_job_http_client_timeout: 3 #seconds
log:
  level: info
  local:
    rotate_count: 50
    rotate_size: 200M
    location: /var/log/harbor
_version: 2.12.0
proxy:
  http_proxy:
  https_proxy:
  no_proxy:
  components:
    - core
    - jobservice
    - trivy
upload_purging:
  enabled: true
  age: 168h
  interval: 24h
  dryrun: false
cache:
  enabled: false
  expire_hours: 24
[root@chenby harbor]#

安装harbor

# 进行安装
[root@chenby harbor]# ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 27.3.1

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.29.7

[Step 2]: loading Harbor images ...
910db7c25623: Loading layer [==================================================>]  40.51MB/40.51MB
c8cd0a1f5b0b: Loading layer [==================================================>]  107.6MB/107.6MB
15d8ff051c07: Loading layer [==================================================>]  46.48MB/46.48MB
d197fd97c185: Loading layer [==================================================>]  13.77MB/13.77MB
d88ec2163d81: Loading layer [==================================================>]  66.05kB/66.05kB
e63d6d00357d: Loading layer [==================================================>]   2.56kB/2.56kB
b802bc40d720: Loading layer [==================================================>]  1.536kB/1.536kB
8225980335b5: Loading layer [==================================================>]  12.29kB/12.29kB
3175598f5b32: Loading layer [==================================================>]  2.746MB/2.746MB
ef05ddf12dfe: Loading layer [==================================================>]  525.3kB/525.3kB
Loaded image: goharbor/prepare:v2.12.0
32cd15a4ebdd: Loading layer [==================================================>]  16.27MB/16.27MB
0dd22cb0da1b: Loading layer [==================================================>]  190.2MB/190.2MB
ac30f78bb9c1: Loading layer [==================================================>]  26.08MB/26.08MB
527459edc5ee: Loading layer [==================================================>]   18.6MB/18.6MB
0fe3e34fe571: Loading layer [==================================================>]   5.12kB/5.12kB
eb0883932a36: Loading layer [==================================================>]  6.144kB/6.144kB
49b31970580b: Loading layer [==================================================>]  3.072kB/3.072kB
478aa400459f: Loading layer [==================================================>]  2.048kB/2.048kB
c39207896960: Loading layer [==================================================>]   2.56kB/2.56kB
e3a89007fad0: Loading layer [==================================================>]   7.68kB/7.68kB
Loaded image: goharbor/harbor-db:v2.12.0
eb105901976e: Loading layer [==================================================>]  11.57MB/11.57MB
4c386227a4e4: Loading layer [==================================================>]  3.584kB/3.584kB
4f442ab7cc4c: Loading layer [==================================================>]   2.56kB/2.56kB
2fa6704b1ae6: Loading layer [==================================================>]  59.63MB/59.63MB
65c014dfa82d: Loading layer [==================================================>]  60.42MB/60.42MB
Loaded image: goharbor/harbor-jobservice:v2.12.0
4cab912836a2: Loading layer [==================================================>]  8.614MB/8.614MB
247df5f5c893: Loading layer [==================================================>]  4.096kB/4.096kB
9ee7df405168: Loading layer [==================================================>]  18.13MB/18.13MB
d628a65e4634: Loading layer [==================================================>]  3.072kB/3.072kB
1759c807e026: Loading layer [==================================================>]  36.96MB/36.96MB
bee402e81ccd: Loading layer [==================================================>]  55.88MB/55.88MB
Loaded image: goharbor/harbor-registryctl:v2.12.0
afc604caf53d: Loading layer [==================================================>]  11.57MB/11.57MB
f9eb13f95461: Loading layer [==================================================>]  37.01MB/37.01MB
e98d25e4c661: Loading layer [==================================================>]  4.608kB/4.608kB
8dd3c4f177e1: Loading layer [==================================================>]   37.8MB/37.8MB
Loaded image: goharbor/harbor-exporter:v2.12.0
31e9c30e4a21: Loading layer [==================================================>]  16.27MB/16.27MB
bfcf2dfddce8: Loading layer [==================================================>]  125.1MB/125.1MB
1660b90f9dc7: Loading layer [==================================================>]  3.072kB/3.072kB
93c9be43608f: Loading layer [==================================================>]   59.9kB/59.9kB
d69d92256927: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.12.0
769c4aa8c0a4: Loading layer [==================================================>]  8.614MB/8.614MB
9cd556727275: Loading layer [==================================================>]  4.096kB/4.096kB
0edc0bc0fa32: Loading layer [==================================================>]  3.072kB/3.072kB
30823cd3e953: Loading layer [==================================================>]  18.13MB/18.13MB
31ffd46d4827: Loading layer [==================================================>]  18.92MB/18.92MB
Loaded image: goharbor/registry-photon:v2.12.0
8f8c2600e204: Loading layer [==================================================>]  130.1MB/130.1MB
676f1d057a8c: Loading layer [==================================================>]  6.731MB/6.731MB
71425f9960bc: Loading layer [==================================================>]  252.9kB/252.9kB
8ce274b4eb81: Loading layer [==================================================>]  1.497MB/1.497MB
Loaded image: goharbor/harbor-portal:v2.12.0
4ed6c9567d72: Loading layer [==================================================>]  11.57MB/11.57MB
68c5cae40c58: Loading layer [==================================================>]  3.584kB/3.584kB
a29956692eb6: Loading layer [==================================================>]   2.56kB/2.56kB
d4eac84f665a: Loading layer [==================================================>]  70.77MB/70.77MB
c2d39ec31cb3: Loading layer [==================================================>]  5.632kB/5.632kB
81df0033286e: Loading layer [==================================================>]  126.5kB/126.5kB
847040daf450: Loading layer [==================================================>]  201.7kB/201.7kB
cba56604cbfc: Loading layer [==================================================>]  71.89MB/71.89MB
6d8fda582e88: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.12.0
8dd98fe70bfa: Loading layer [==================================================>]  139.8MB/139.8MB
c0691b0983da: Loading layer [==================================================>]  3.584kB/3.584kB
a205646db971: Loading layer [==================================================>]  3.072kB/3.072kB
36bea9385de7: Loading layer [==================================================>]   2.56kB/2.56kB
624bbccc716a: Loading layer [==================================================>]  3.072kB/3.072kB
cee989d2b0b0: Loading layer [==================================================>]  3.584kB/3.584kB
73035228c2e1: Loading layer [==================================================>]  20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.12.0
d397faf073f1: Loading layer [==================================================>]  130.1MB/130.1MB
Loaded image: goharbor/nginx-photon:v2.12.0
3e1f1096c4bf: Loading layer [==================================================>]  9.106MB/9.106MB
9cc192b1539e: Loading layer [==================================================>]  4.096kB/4.096kB
a4448f8ca935: Loading layer [==================================================>]  3.072kB/3.072kB
38c665e4daa5: Loading layer [==================================================>]  133.8MB/133.8MB
867c3a3ec63e: Loading layer [==================================================>]  15.55MB/15.55MB
e04b98ae7085: Loading layer [==================================================>]  150.1MB/150.1MB
Loaded image: goharbor/trivy-adapter-photon:v2.12.0


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
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
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
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.4s 
 ✔ Container harbor-db          Started                                                                          0.6s 
 ✔ Container redis              Started                                                                          0.7s 
 ✔ Container registryctl        Started                                                                          0.7s 
 ✔ Container harbor-portal      Started                                                                          0.7s 
 ✔ Container registry           Started                                                                          0.6s 
 ✔ Container harbor-core        Started                                                                          0.8s 
 ✔ Container nginx              Started                                                                          1.1s 
 ✔ Container harbor-jobservice  Started                                                                          1.0s 
✔ ----Harbor has been installed and started successfully.----
[root@chenby harbor]#

配置解析和docker

# FQDN解析
cat >> /etc/hosts <<EOF
192.168.1.120 z.oiox.cn
EOF


# 例如docker的配置
# 如果没有正式的域名以及ssl证书就需要配置 insecure-registries 参数
[root@chenby ~]# cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "insecure-registries": ["z.oiox.cn:18082"],
  "registry-mirrors": [
    "https://xxxxx.mirror.aliyuncs.com"
  ],
  "max-concurrent-downloads": 10,
  "log-driver": "json-file",
  "log-level": "warn",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
    },
  "data-root": "/var/lib/docker"
}
EOF

# 重新启动docker
[root@chenby ~]# systemctl restart docker && systemctl status docker -l

测试使用

# 登陆 
[root@chenby ~]# docker login z.oiox.cn:18082
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credential-stores

Login Succeeded
[root@chenby ~]# 

# 构建镜像
[root@chenby ~]# cat > Dockerfile <<EOF
FROM nginx
RUN echo '这是一个本地构建的nginx镜像,第一版' > /usr/share/nginx/html/index.html
EOF

docker build -t z.oiox.cn:18082/library/cby:v1 .


[root@chenby ~]# cat > Dockerfile <<EOF
FROM nginx
RUN echo '这是一个本地构建的nginx镜像,第二版' > /usr/share/nginx/html/index.html
EOF

docker build -t z.oiox.cn:18082/library/cby:v2 .


docker push z.oiox.cn:18082/library/cby:v1
docker push z.oiox.cn:18082/library/cby:v2

docker rmi z.oiox.cn:18082/library/cby:v1
docker rmi z.oiox.cn:18082/library/cby:v2

docker pull z.oiox.cn:18082/library/cby:v1
docker pull z.oiox.cn:18082/library/cby:v2

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、51CTO、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

文章主要发布于微信公众号

相关文章
|
6天前
|
存储 人工智能 弹性计算
阿里云弹性计算_加速计算专场精华概览 | 2024云栖大会回顾
2024年9月19-21日,2024云栖大会在杭州云栖小镇举行,阿里云智能集团资深技术专家、异构计算产品技术负责人王超等多位产品、技术专家,共同带来了题为《AI Infra的前沿技术与应用实践》的专场session。本次专场重点介绍了阿里云AI Infra 产品架构与技术能力,及用户如何使用阿里云灵骏产品进行AI大模型开发、训练和应用。围绕当下大模型训练和推理的技术难点,专家们分享了如何在阿里云上实现稳定、高效、经济的大模型训练,并通过多个客户案例展示了云上大模型训练的显著优势。
|
9天前
|
存储 人工智能 调度
阿里云吴结生:高性能计算持续创新,响应数据+AI时代的多元化负载需求
在数字化转型的大潮中,每家公司都在积极探索如何利用数据驱动业务增长,而AI技术的快速发展更是加速了这一进程。
|
1天前
|
并行计算 前端开发 物联网
全网首发!真·从0到1!万字长文带你入门Qwen2.5-Coder——介绍、体验、本地部署及简单微调
2024年11月12日,阿里云通义大模型团队正式开源通义千问代码模型全系列,包括6款Qwen2.5-Coder模型,每个规模包含Base和Instruct两个版本。其中32B尺寸的旗舰代码模型在多项基准评测中取得开源最佳成绩,成为全球最强开源代码模型,多项关键能力超越GPT-4o。Qwen2.5-Coder具备强大、多样和实用等优点,通过持续训练,结合源代码、文本代码混合数据及合成数据,显著提升了代码生成、推理和修复等核心任务的性能。此外,该模型还支持多种编程语言,并在人类偏好对齐方面表现出色。本文为周周的奇妙编程原创,阿里云社区首发,未经同意不得转载。
|
6天前
|
人工智能 运维 双11
2024阿里云双十一云资源购买指南(纯客观,无广)
2024年双十一,阿里云推出多项重磅优惠,特别针对新迁入云的企业和初创公司提供丰厚补贴。其中,36元一年的轻量应用服务器、1.95元/小时的16核60GB A10卡以及1元购域名等产品尤为值得关注。这些产品不仅价格亲民,还提供了丰富的功能和服务,非常适合个人开发者、学生及中小企业快速上手和部署应用。
|
17天前
|
自然语言处理 数据可视化 前端开发
从数据提取到管理:合合信息的智能文档处理全方位解析【合合信息智能文档处理百宝箱】
合合信息的智能文档处理“百宝箱”涵盖文档解析、向量化模型、测评工具等,解决了复杂文档解析、大模型问答幻觉、文档解析效果评估、知识库搭建、多语言文档翻译等问题。通过可视化解析工具 TextIn ParseX、向量化模型 acge-embedding 和文档解析测评工具 markdown_tester,百宝箱提升了文档处理的效率和精确度,适用于多种文档格式和语言环境,助力企业实现高效的信息管理和业务支持。
3936 2
从数据提取到管理:合合信息的智能文档处理全方位解析【合合信息智能文档处理百宝箱】
|
6天前
|
算法 安全 网络安全
阿里云SSL证书双11精选,WoSign SSL国产证书优惠
2024阿里云11.11金秋云创季活动火热进行中,活动月期间(2024年11月01日至11月30日)通过折扣、叠加优惠券等多种方式,阿里云WoSign SSL证书实现优惠价格新低,DV SSL证书220元/年起,助力中小企业轻松实现HTTPS加密,保障数据传输安全。
508 3
阿里云SSL证书双11精选,WoSign SSL国产证书优惠
|
12天前
|
安全 数据建模 网络安全
2024阿里云双11,WoSign SSL证书优惠券使用攻略
2024阿里云“11.11金秋云创季”活动主会场,阿里云用户通过完成个人或企业实名认证,可以领取不同额度的满减优惠券,叠加折扣优惠。用户购买WoSign SSL证书,如何叠加才能更加优惠呢?
987 3
|
10天前
|
机器学习/深度学习 存储 人工智能
白话文讲解大模型| Attention is all you need
本文档旨在详细阐述当前主流的大模型技术架构如Transformer架构。我们将从技术概述、架构介绍到具体模型实现等多个角度进行讲解。通过本文档,我们期望为读者提供一个全面的理解,帮助大家掌握大模型的工作原理,增强与客户沟通的技术基础。本文档适合对大模型感兴趣的人员阅读。
424 18
白话文讲解大模型| Attention is all you need
|
5天前
|
数据采集 人工智能 API
Qwen2.5-Coder深夜开源炸场,Prompt编程的时代来了!
通义千问团队开源「强大」、「多样」、「实用」的 Qwen2.5-Coder 全系列,致力于持续推动 Open Code LLMs 的发展。
|
10天前
|
算法 数据建模 网络安全
阿里云SSL证书2024双11优惠,WoSign DV证书220元/年起
2024阿里云11.11金秋云创季火热进行中,活动月期间(2024年11月01日至11月30日),阿里云SSL证书限时优惠,部分证书产品新老同享75折起;通过优惠折扣、叠加满减优惠券等多种方式,阿里云WoSign SSL证书将实现优惠价格新低,DV SSL证书220元/年起。
562 5