私有的docker私有镜像站仓库harbor

简介: 私有的docker私有镜像站仓库harbor

需要准备的文件
harbor 方便在企业内部实现私有的容器镜像仓库,方便镜像的分发。

需要准备3个文件
docker compose 文件
harbor 文件
TLS 证书文件
docker hub 在部署当中需要 docker compose 来做容器的编排部署。

部署 harbor 有两种模式,一种是在线模式,一种是离线模式,在线模式由于受到网络环境的影响部署的时间会比较长,网络就会不稳定就会导致无法正常使用,所以一般也就推荐使用离线部署的模式,离线部署就需要用到离线的包。

在访问 harbor 的过程中,http 与 https 这两种协议都可以使用,为了安全性就要使用 SSL 证书,在 harbor 的配置文件当中都会有所涉及。

▷ 获取 docker compose 文件
对于安装 docker compose 文件的时候,CPU 建议配置到2核,内存是4G以上为满足harbor后面的增长需求。

这里我使用的 docker compose 的下载地址:

https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/56e530c4-050d-4fb2-a8ab-b9451171b912?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241010%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241010T150425Z&X-Amz-Expires=300&X-Amz-Signature=e5fb58d7f455d5e24eb2b35b9b3d92fb667c57e0282021b25a1a994fbe0daee8&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream
[root@server bin]# pwd
/root/bin

[root@server bin]# mv docker-compose-linux-x86_64 docker-compose

[root@server bin]# chmod +x docker-compose

[root@server bin]# docker-compose version
Docker Compose version v2.29.6

▷ 获取 harbor 文件
[root@server bin]# cd /home

[root@server home]# wget https://github.com/goharbor/harbor/releases/download/v2.11.1/harbor-offline-installer-v2.11.1.tgz
--snip--
2024-10-10 23:30:00 (1.91 MB/s) - ‘harbor-offline-installer-v2.11.1.tgz’ saved [658192407/658192407]

[root@server home]# ll
total 642768
-rw-r--r--. 1 root root 658192407 Aug 21 10:27 harbor-offline-installer-v2.11.1.tgz

▷ 准备证书文件-获取TLS文件
https://www.toolhelper.cn/SSL/SSLGenerate 用于自己实验使用的证书生成网站。

这里准备的文件是 harbor-offline-installer-v2.11.1.tgz 这个文件。

此时在 /home 目录中则就有 harbor 的文件 和 证书文件 这两个文件。

[root@server home]# ll
total 642780
-rw-r--r--. 1 root root 658192407 Aug 21 10:27 harbor-offline-installer-v2.11.1.tgz
-rw-r--r--. 1 root root 5253 Oct 10 23:50 ssl_generate.zip

▶ 解压与配置文件

▷ 解压和配置准备
解压上面的两个文件

[root@server home]# tar -xzvf harbor-offline-installer-v2.11.1.tgz
harbor/harbor.v2.11.1.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl

[root@server home]# unzip ssl_generate.zip
Archive: ssl_generate.zip
inflating: generate.pfx
inflating: cert.pem
inflating: private.key
此时就有:

[root@server home]# ll
total 642788
-rw-r--r--. 1 root root 1263 Oct 10 23:36 cert.pem
-rw-r--r--. 1 root root 2620 Oct 10 23:36 generate.pfx
drwxr-xr-x. 2 root root 123 Oct 11 12:20 harbor
-rw-r--r--. 1 root root 658192407 Aug 21 10:27 harbor-offline-installer-v2.11.1.tgz
-rw-r--r--. 1 root root 1714 Oct 10 23:36 private.key
-rw-r--r--. 1 root root 5253 Oct 10 23:50 ssl_generate.zip
此时将认证文件放在 harbor 目录下:

[root@server home]# ll
total 642788
-rw-r--r--. 1 root root 1263 Oct 10 23:36 cert.pem
-rw-r--r--. 1 root root 2620 Oct 10 23:36 generate.pfx
drwxr-xr-x. 2 root root 123 Oct 11 12:20 harbor
-rw-r--r--. 1 root root 658192407 Aug 21 10:27 harbor-offline-installer-v2.11.1.tgz
drwx------. 2 hp hp 83 Aug 15 09:34 hp
-rw-r--r--. 1 root root 1714 Oct 10 23:36 private.key
-rw-r--r--. 1 root root 5253 Oct 10 23:50 ssl_generate.zip

[root@server home]# mv cert.pem generate.pfx private.key harbor
进入 harbor 目录后,找到 harbor 的配置文件,这个配置文件是 harbor.yml.tmpl 用于生效的 harbor 的配置文件是 harbor.yml。

使用 cp 既保存了先前的 harbor.yml.tmpl 也有了配置文件 harbor.yml。

[root@server home]# cd harbor/
[root@server harbor]# cp harbor.yml.tmpl harbor.yml

▷ 配置
[root@server harbor]# vim harbor.yml
--snip--
3 # The IP address or hostname to access admin UI and registry service.
4 # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
5 hostname: reg.mydomain.com

==> 修改第5行
5 hostname: www.harborexample.com
hostname:修改成域名或者是 IP 地址,这里我使用的是 www.harborexample.com 域名。

16 # The path of cert and key files for nginx
17 certificate: /your/certificate/path
18 private_key: /your/private/key/path

==> 修改第 17-18 行
17 certificate: /home/harbor/cert.pem
18 private_key: /home/harbor/private.key

后面的 47 行默认配置了 harbor 的 admin 用户登陆的密码是 Harbor12345,datebase 的数据密码是 root123 。

47 harbor_admin_password: Harbor12345
48
49 # Harbor DB configuration
50 database:
51 # The password for the root user of Harbor DB. Change this before any production use.
52 password: root123

▶ 执行与预备安装脚本
执行预备脚本:

[root@server harbor]# ./prepare
prepare base dir is set to /home/harbor
Unable to find image 'goharbor/prepare:v2.11.1' locally
v2.11.1: Pulling from goharbor/prepare
21fde6fe7256: Pull complete
e7d411dc7b71: Pull complete
956686c6154d: Pull complete
ccc241b37d9f: Pull complete
--snip--
这会拉取镜像文件。

执行安装脚本

[root@server harbor]# ./install.sh

[Step 0]: checking if docker is installed ...
--sni--
[+] Running 10/10
✔ Network harbor_harbor Created 0.2s
✔ Container harbor-log Started 0.5s
✔ Container harbor-portal Started 1.8s
✔ Container registry Started 1.9s
✔ Container redis Started 1.4s
✔ Container harbor-db Started 1.9s
✔ Container registryctl Started 1.8s
✔ Container harbor-core Started 2.2s
✔ Container nginx Started 3.4s
✔ Container harbor-jobservice Started 2.9s
✔ ----Harbor has been installed and started successfully.----
这样 harbor 的配置与安装就算简单的完成了。

[kod.tjbxt.com)
[kod.hehuakeng.com)
[kod.gbhospital.com)
[kod.think-cg.net)
[kod.shxiduguolv.com)
[kod.dzmwood.com)
[kod.lhjdfc.com)
[kod.86tax.net)

用户名是 admin, 密码是 Harbor12345。

▶ 验证运行情况
[root@server harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5b90d66a877 goharbor/harbor-jobservice:v2.11.1 "/harbor/entrypoint.…" 6 minutes ago Up 6 minutes (healthy) harbor-jobservice
6f3cae3fd8fa goharbor/nginx-photon:v2.11.1 "nginx -g 'daemon of…" 6 minutes ago Up 6 minutes (healthy) 0.0.0.0:80->8080/tcp, [::]:80->8080/tcp, 0.0.0.0:443->8443/tcp, [::]:443->8443/tcp nginx
24b256df6c94 goharbor/harbor-core:v2.11.1 "/harbor/entrypoint.…" 6 minutes ago Up 6 minutes (healthy) harbor-core
7882833acb96 goharbor/harbor-db:v2.11.1 "/docker-entrypoint.…" 6 minutes ago Up 6 minutes (healthy) harbor-db
743eb9f226e6 goharbor/redis-photon:v2.11.1 "redis-server /etc/r…" 6 minutes ago Up 6 minutes (healthy) redis
d3045620b287 goharbor/registry-photon:v2.11.1 "/home/harbor/entryp…" 6 minutes ago Up 6 minutes (healthy) registry
27a4de039809 goharbor/harbor-registryctl:v2.11.1 "/home/harbor/start.…" 6 minutes ago Up 6 minutes (healthy) registryctl
426620cf7a97 goharbor/harbor-portal:v2.11.1 "nginx -g 'daemon of…" 6 minutes ago Up 6 minutes (healthy) harbor-portal
605cae889833 goharbor/harbor-log:v2.11.1 "/bin/sh -c /usr/loc…" 6 minutes ago Up 6 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
harbor 的运行依赖于9个容器!

相关文章
|
24天前
|
弹性计算 人工智能 架构师
阿里云携手Altair共拓云上工业仿真新机遇
2024年9月12日,「2024 Altair 技术大会杭州站」成功召开,阿里云弹性计算产品运营与生态负责人何川,与Altair中国技术总监赵阳在会上联合发布了最新的“云上CAE一体机”。
阿里云携手Altair共拓云上工业仿真新机遇
|
16天前
|
存储 关系型数据库 分布式数据库
GraphRAG:基于PolarDB+通义千问+LangChain的知识图谱+大模型最佳实践
本文介绍了如何使用PolarDB、通义千问和LangChain搭建GraphRAG系统,结合知识图谱和向量检索提升问答质量。通过实例展示了单独使用向量检索和图检索的局限性,并通过图+向量联合搜索增强了问答准确性。PolarDB支持AGE图引擎和pgvector插件,实现图数据和向量数据的统一存储与检索,提升了RAG系统的性能和效果。
|
20天前
|
机器学习/深度学习 算法 大数据
【BetterBench博士】2024 “华为杯”第二十一届中国研究生数学建模竞赛 选题分析
2024“华为杯”数学建模竞赛,对ABCDEF每个题进行详细的分析,涵盖风电场功率优化、WLAN网络吞吐量、磁性元件损耗建模、地理环境问题、高速公路应急车道启用和X射线脉冲星建模等多领域问题,解析了问题类型、专业和技能的需要。
2577 22
【BetterBench博士】2024 “华为杯”第二十一届中国研究生数学建模竞赛 选题分析
|
18天前
|
人工智能 IDE 程序员
期盼已久!通义灵码 AI 程序员开启邀测,全流程开发仅用几分钟
在云栖大会上,阿里云云原生应用平台负责人丁宇宣布,「通义灵码」完成全面升级,并正式发布 AI 程序员。
|
3天前
|
JSON 自然语言处理 数据管理
阿里云百炼产品月刊【2024年9月】
阿里云百炼产品月刊【2024年9月】,涵盖本月产品和功能发布、活动,应用实践等内容,帮助您快速了解阿里云百炼产品的最新动态。
阿里云百炼产品月刊【2024年9月】
|
2天前
|
存储 人工智能 搜索推荐
数据治理,是时候打破刻板印象了
瓴羊智能数据建设与治理产品Datapin全面升级,可演进扩展的数据架构体系为企业数据治理预留发展空间,推出敏捷版用以解决企业数据量不大但需构建数据的场景问题,基于大模型打造的DataAgent更是为企业用好数据资产提供了便利。
164 2
|
20天前
|
机器学习/深度学习 算法 数据可视化
【BetterBench博士】2024年中国研究生数学建模竞赛 C题:数据驱动下磁性元件的磁芯损耗建模 问题分析、数学模型、python 代码
2024年中国研究生数学建模竞赛C题聚焦磁性元件磁芯损耗建模。题目背景介绍了电能变换技术的发展与应用,强调磁性元件在功率变换器中的重要性。磁芯损耗受多种因素影响,现有模型难以精确预测。题目要求通过数据分析建立高精度磁芯损耗模型。具体任务包括励磁波形分类、修正斯坦麦茨方程、分析影响因素、构建预测模型及优化设计条件。涉及数据预处理、特征提取、机器学习及优化算法等技术。适合电气、材料、计算机等多个专业学生参与。
1576 16
【BetterBench博士】2024年中国研究生数学建模竞赛 C题:数据驱动下磁性元件的磁芯损耗建模 问题分析、数学模型、python 代码
|
22天前
|
编解码 JSON 自然语言处理
通义千问重磅开源Qwen2.5,性能超越Llama
击败Meta,阿里Qwen2.5再登全球开源大模型王座
978 14
|
4天前
|
Linux 虚拟化 开发者
一键将CentOs的yum源更换为国内阿里yum源
一键将CentOs的yum源更换为国内阿里yum源
221 2
|
17天前
|
人工智能 开发框架 Java
重磅发布!AI 驱动的 Java 开发框架:Spring AI Alibaba
随着生成式 AI 的快速发展,基于 AI 开发框架构建 AI 应用的诉求迅速增长,涌现出了包括 LangChain、LlamaIndex 等开发框架,但大部分框架只提供了 Python 语言的实现。但这些开发框架对于国内习惯了 Spring 开发范式的 Java 开发者而言,并非十分友好和丝滑。因此,我们基于 Spring AI 发布并快速演进 Spring AI Alibaba,通过提供一种方便的 API 抽象,帮助 Java 开发者简化 AI 应用的开发。同时,提供了完整的开源配套,包括可观测、网关、消息队列、配置中心等。
735 9