首页 > 其他分享 >安装Harbor镜像仓库

安装Harbor镜像仓库

时间:2024-11-17 11:57:31浏览次数:1  
标签:kB layer Loading harbor MB 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、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

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

标签:kB,layer,Loading,harbor,MB,Harbor,仓库,镜像,docker
From: https://www.cnblogs.com/chenby/p/18550397

相关文章

  • 镜像部署 Node.js 环境
    操作场景腾讯云市场中提供了例如包含多种操作系统、热门软件等不同类型的镜像。您可选择这些镜像,在腾讯云云服务器(CVM)上快速部署具有较高稳定性和安全性的软件环境以及个人网站。本文档介绍在Linux操作系统的腾讯云云服务器(CVM)上通过镜像完成Node.js环境部署。技能要求......
  • zlibrary镜像网页,国内可用官网入口及客户端/app(持续更新)
    Z-Library(也被称为Z-Lib)是一个在线的、开源的、免费的数字图书馆项目,旨在提供各种书籍、文章、科学论文、杂志、漫画等资源的访问。该项目成立于2009年,至今已经收录了超过10,000,000册书籍和80,000,000篇文章。zlibrary电脑客户端/安卓appzlibrary(windows/mac/安卓)安装包下......
  • 【学习心得】数据分析三剑客跟学Gitee仓库
        之前,自己在学习数据分析过程中的学习方法和思路,将那些摸索与实践中的心得体会分享出来,能够得到大家的喜欢、点赞我非常高兴,谢谢大家的支持!这些正面的反馈对我来说,不仅是莫大的鼓励,更是持续前进的动力源泉。然而,程序员有一句名言:Talkischeap,Showmethecode.......
  • flask毕设超市仓库管理系统(论文+程序)
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容选题背景超市仓库管理系统是现代零售业运营中的重要组成部分,其高效运作直接关系到企业的成本控制、库存管理以及客户满意度。随着信息技术的飞速发......
  • docker容器镜像的制作、使用以及传递
    目录制作容器镜像使用Dockerfile制作镜像准备所需文件构建镜像怎么不使用基础镜像来构建容器镜像使用容器镜像传递容器镜像这篇文章讨论一下怎么使用docker制作容器镜像,容器镜像的使用,以及怎么传递容器镜像。制作容器镜像docker制作容器镜像推荐的方法就是使用Doc......
  • 写一个自动构建docker镜像推送至私有仓库并且部署的脚本
    脚本如下#catbuild/docker.sh#!/usr/bin/envbash#获取当前分支名BRANCH=`gitrev-parse--abbrev-refHEAD`#获取git提交的标识符用于Docker镜像的标签BUILD_TAG="$(gitrev-parse--short$BRANCH)"HARBOR_URL="harbor.xxx.com"echo"Tagis${BUILD_TAG}"......
  • 自动化构建镜像:Packer
    在介绍Packer之前,先来回顾一下未使用Packer时自定义虚拟机镜像的步骤。先在本地启动一个虚拟机,从安装系统开始,再进行自定义配置或应用安装,最后封装压缩成镜像,详细操作步骤可以参考我之前写的文档,制作Centos7镜像:https://robin-2016.github.io/2019/04/08/制作openstack的centos7......
  • 5分钟上手 Docker:镜像优化
    Docker是一种流行的容器化技术,它允许开发者将应用程序及其所有依赖打包成一个标准化的单元——镜像。优化Docker镜像不仅能减小镜像的体积,提高下载和部署速度,还能增强安全性。在本文中,我们将介绍一些镜像优化的技巧,帮助你在5分钟内快速上手Docker镜像的优化。1.使用合适......
  • Z-Library入口网站 zlibrary国内可访问镜像地址(长期更新)
    Z-Library(简称z-lib,前身为BookFinder)是一个影子图书馆和开放获取文件分享计划,用户可在此网络下载期刊文章以及各种类型的书籍。截止2022年6月12日,该网站共收录了10,456,034本书和84,837,646篇文章。不过似乎很多用户还不知道,仍在使用一些不安全的仿冒山寨网站,甚至钓鱼网站。......
  • 数据仓库
    什么是数据仓库?数据仓库是面向主题的,集成的,随时间变化的,非易失的集合。数据仓库的模型---星型模型事实表连接着多个维度表,是单维度的每个维度上不存在再连接维度表了特点:不存在渐变维度,非正规化,有冗余数据,查询效率比较高数据仓库的模型--雪花模型多个维度表连接着事实......