离线安装harbor:使用docker-compose方式

目录

  • 一、安装docker
  • 二、安装docker-compose
    • 1、下载docker-compose
    • 2、安装docker-compose
    • 3、验证安装效果
  • 三、安装harbor
    • 1、下载harbor
    • 2、解压harbor
    • 3、修改harbor.yml
    • 4、安装harbor
    • 5、修改docker配置文件
    • 6、配置harbor自启动
  • 四、登录harbor
  • 五、测试harbor
    • 1、测试在linux上登录harbor
    • 2、测试通过docker命令推送镜像到harbor
    • 3、测试通过docker命令从harbor仓库下载镜像

一、安装docker

参照博客docker学习文档来安装docker

二、安装docker-compose

1、下载docker-compose

下载链接:https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-linux-x86_64

考虑到网速原因,这里提供百度网盘下载信息:

链接:https://pan.baidu.com/s/1SHSUkDL-OPJXxaY-QXqZWQ?pwd=isci

提取码:isci

2、安装docker-compose

// 1、将文件移动到/usr/local/bin下,并改名为docker-compose
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

// 2、添加权限
chmod +x /usr/local/bin/docker-compose

3、验证安装效果

// 任意找一个目录执行,只要能看到“Docker Compose version v2.3.4”就可以了
docker-compose -v

三、安装harbor

1、下载harbor

下载链接:https://github.com/goharbor/harbor/releases/download/v2.4.2/harbor-offline-installer-v2.4.2.tgz

2、解压harbor

tar -zxvf harbor-offline-installer-v2.3.1.tgz -C /opt/harbor/

3、修改harbor.yml

// 1、复制harbor.yml.tmpl,并且改名为harbor.yml
cp harbor.yml.tmpl harbor.yml

// 2、修改harbor.yml中的内容,注意不要在上述yml中添加中文
// 修改主机ip:将hostname属性值修改成主机ip,例如:192.168.1.10或reg.yourdomain.com。不要使用localhost或127.0.0.1作为主机名;比如现在我的主机ip是192.168.56.10
hostname 192.168.56.10
// 修改harbor访问端口:将port属性值修改成harbor访问端口,比如82,我们在浏览器访问harbor首页的时候可以使用“http://192.168.56.10:82”;搜索“http related config”,下面的port值就是端口
http:
  port: 82
// 修改harbor仓库密码:将harbor_admin_password属性值修改成密码,其中默认用户名/密码为admin/Harbor12345
harbor_admin_password: admin123456
// 修改PostgreSQL数据库的root用户密码:将password属性值修改成密码;搜索“Harbor DB configuration”,下面的password值就是密码
database:
  password: 123456
// 修改harbor数据存储位置:将data_volume属性值修改成数据存储位置,如果原来没有这个存储位置,记得提前创建,例如:/opt/harbor-data
data_volume: /opt/harbor-data
// 修改harbor日志存储位置:将location属性值修改成日志存储位置;搜索“Log configurations”,下面的location值就是日志存储位置;注意:我们这里没有修改
log:
  level: info
  local:
    rotate_count: 50
    rotate_size: 200M
    location: /var/log/harbor
// 注释以下内容,避免出现错误“The protocol is https but attribute ssl_cert is not set”
https:
  # https port for harbor, default is 443
  port: 443
  # The path of cert and key files for nginx
  certificate: /your/certificate/path
  private_key: /your/private/key/path

下面把我修改之后的harbor.yml示例文件发出来,被修改的位置上面添加了update by mingkuaidexuanmi61

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
# update by mingkuaidexuanmi61
hostname: 192.168.56.10

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  # update by mingkuaidexuanmi61
  port: 82

# update by mingkuaidexuanmi61
# https related config
# https:
#   # https port for harbor, default is 443
#   port: 443
#   # The path of cert and key files for nginx
#   certificate: /your/certificate/path
#   private_key: /your/private/key/path

# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
#   # set enabled to true means internal tls is enabled
#   enabled: true
#   # put your cert and key files on dir
#   dir: /etc/harbor/tls/internal

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
# update by mingkuaidexuanmi61
harbor_admin_password: admin123456

# Harbor DB configuration
database:
  # The password for the root user of Harbor DB. Change this before any production use.
# update by mingkuaidexuanmi61
  password: 123456
  # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
  max_idle_conns: 100
  # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
  # Note: the default number of connections is 1024 for postgres of harbor.
  max_open_conns: 900

# The default data volume
# update by mingkuaidexuanmi61
data_volume: /opt/harbor-data

# Harbor Storage settings by default is using /data dir on local filesystem
# Uncomment storage_service setting If you want to using external storage
# storage_service:
#   # ca_bundle is the path to the custom root ca certificate, which will be injected into the truststore
#   # of registry's and chart repository's containers.  This is usually needed when the user hosts a internal storage with self signed certificate.
#   ca_bundle:

#   # storage backend, default is filesystem, options include filesystem, azure, gcs, s3, swift and oss
#   # for more info about this configuration please refer https://docs.docker.com/registry/configuration/
#   filesystem:
#     maxthreads: 100
#   # set disable to true when you want to disable registry redirect
#   redirect:
#     disabled: false

# Trivy configuration
#
# Trivy DB contains vulnerability information from NVD, Red Hat, and many other upstream vulnerability databases.
# It is downloaded by Trivy from the GitHub release page https://github.com/aquasecurity/trivy-db/releases and cached
# in the local file system. In addition, the database contains the update timestamp so Trivy can detect whether it
# should download a newer version from the Internet or use the cached one. Currently, the database is updated every
# 12 hours and published as a new release to GitHub.
trivy:
  # ignoreUnfixed The flag to display only fixed vulnerabilities
  ignore_unfixed: false
  # skipUpdate The flag to enable or disable Trivy DB downloads from GitHub
  #
  # You might want to enable this flag in test or CI/CD environments to avoid GitHub rate limiting issues.
  # If the flag is enabled you have to download the `trivy-offline.tar.gz` archive manually, extract `trivy.db` and
  # `metadata.json` files and mount them in the `/home/scanner/.cache/trivy/db` path.
  skip_update: false
  #
  # insecure The flag to skip verifying registry certificate
  insecure: false
  # github_token The GitHub access token to download Trivy DB
  #
  # Anonymous downloads from GitHub are subject to the limit of 60 requests per hour. Normally such rate limit is enough
  # for production operations. If, for any reason, it's not enough, you could increase the rate limit to 5000
  # requests per hour by specifying the GitHub access token. For more details on GitHub rate limiting please consult
  # https://developer.github.com/v3/#rate-limiting
  #
  # You can create a GitHub token by following the instructions in
  # https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
  #
  # github_token: xxx

jobservice:
  # Maximum number of job workers in job service
  max_job_workers: 10

notification:
  # Maximum retry count for webhook job
  webhook_job_max_retry: 10

chart:
  # Change the value of absolute_url to enabled can enable absolute url in chart
  absolute_url: disabled

# Log configurations
log:
  # options are debug, info, warning, error, fatal
  level: info
  # configs for logs in local storage
  local:
    # Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
    rotate_count: 50
    # Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes.
    # If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G
    # are all valid.
    rotate_size: 200M
    # The directory on your host that store log
    location: /var/log/harbor

  # Uncomment following lines to enable external syslog endpoint.
  # external_endpoint:
  #   # protocol used to transmit log to external endpoint, options is tcp or udp
  #   protocol: tcp
  #   # The host of external endpoint
  #   host: localhost
  #   # Port of external endpoint
  #   port: 5140

#This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
_version: 2.3.0

# Uncomment external_database if using external database.
# external_database:
#   harbor:
#     host: harbor_db_host
#     port: harbor_db_port
#     db_name: harbor_db_name
#     username: harbor_db_username
#     password: harbor_db_password
#     ssl_mode: disable
#     max_idle_conns: 2
#     max_open_conns: 0
#   notary_signer:
#     host: notary_signer_db_host
#     port: notary_signer_db_port
#     db_name: notary_signer_db_name
#     username: notary_signer_db_username
#     password: notary_signer_db_password
#     ssl_mode: disable
#   notary_server:
#     host: notary_server_db_host
#     port: notary_server_db_port
#     db_name: notary_server_db_name
#     username: notary_server_db_username
#     password: notary_server_db_password
#     ssl_mode: disable

# Uncomment external_redis if using external Redis server
# external_redis:
#   # support redis, redis+sentinel
#   # host for redis: <host_redis>:<port_redis>
#   # host for redis+sentinel:
#   #  <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3>
#   host: redis:6379
#   password:
#   # sentinel_master_set must be set to support redis+sentinel
#   #sentinel_master_set:
#   # db_index 0 is for core, it's unchangeable
#   registry_db_index: 1
#   jobservice_db_index: 2
#   chartmuseum_db_index: 3
#   trivy_db_index: 5
#   idle_timeout_seconds: 30

# Uncomment uaa for trusting the certificate of uaa instance that is hosted via self-signed cert.
# uaa:
#   ca_file: /path/to/ca

# Global proxy
# Config http proxy for components, e.g. http://my.proxy.com:3128
# Components doesn't need to connect to each others via http proxy.
# Remove component from `components` array if want disable proxy
# for it. If you want use proxy for replication, MUST enable proxy
# for core and jobservice, and set `http_proxy` and `https_proxy`.
# Add domain to the `no_proxy` field, when you want disable proxy
# for some special registry.
proxy:
  http_proxy:
  https_proxy:
  no_proxy:
  components:
    - core
    - jobservice
    - trivy

# metric:
#   enabled: false
#   port: 9090
#   path: /metrics

4、安装harbor

// 1、进入安装文件解压目录
cd /opt/harbor

// 2、安装harbor
./install.sh

5、修改docker配置文件

// 1、打开daemon.json
vi /etc/docker/daemon.json

// 2、添加harbor访问信息,并保存"insecure-registries": ["主机ip:harbor端口"]添加到里面,例如:
{
  "registry-mirrors": ["https://95c1opgi.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.56.10:82"]
}
其中主机ip“192.168.56.10”是安装harbor的主机ip,而端口“82”是我在harbor.yml中设置的http.port值

// 3、应用docker配置,并重启docker
systemctl daemon-reload
systemctl restart docker

6、配置harbor自启动

// 1、编辑harbor.service文件
vi /usr/lib/systemd/system/harbor.service

// 2、将以下内容填充到上述文件中,并保存
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down
[Install]
WantedBy=multi-user.target

// 3、设置开机自启
systemctl enable harbor

四、登录harbor

直接在浏览器上访问即可,其中ip是主机ip,端口是harbor.yml中配置的http.port,比如:http://192.168.56.10:82

其中用户名是admin,密码是admin123456,登录成功后页面如下

在这里插入图片描述

五、测试harbor

1、测试在linux上登录harbor

在linux上输入docker login 主节点ip:82回车即可,比如我的就是docker login 192.168.56.10:82,然后依次输入用户名回车、输入密码回车就可以登录harbor了,如下:

在这里插入图片描述

2、测试通过docker命令推送镜像到harbor

本次测试推送busybox到harbor仓库

首先通过docker pull busybox下载busybox镜像

然后将镜像打成符合推送要求的样子,命令是:docker tag 本地镜像名称:本地镜像版本号 仓库访问地址/项目名称/推送到harbor仓库的镜像名称:推送到harbor仓库的镜像版本号,比如我的就是:

docker tag busybox:latest 192.168.56.10:82/test/busybox:v1.0.0

解释如下:

  • busybox:latest:本地镜像名称:本地镜像版本号

  • 192.168.56.10:82:harbor访问地址
    在这里插入图片描述

  • test:harbor仓库中的项目名称
    在这里插入图片描述

  • busybox:harbor仓库中的镜像名称
    在这里插入图片描述

  • v1.0.0:harbor仓库中的镜像版本号
    在这里插入图片描述

然后把镜像推送到harbor仓库中就可以了(注意:推送之前记得在harbor控制台页面中创建test项目),命令是:docker push 仓库访问地址/项目名称/推送到harbor仓库的镜像名称:推送到harbor仓库的镜像版本号,比如我的就是:

docker push 192.168.56.10:82/test/busybox:v1.0.0

命令执行完成效果如下:

在这里插入图片描述

3、测试通过docker命令从harbor仓库下载镜像

首先删除同名镜像,命令是:docker rmi 仓库访问地址/项目名称/镜像名称:镜像版本号,例如:

docker rmi 192.168.56.10:82/test/busybox:v1.0.0

然后下载镜像,命令是:docker pull 仓库访问地址/项目名称/镜像名称:镜像版本号,例如:

docker pull 192.168.56.10:82/test/busybox:v1.0.0

命令执行完成效果如下:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/304065.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

行云部署成长之路 -- 慢 SQL 优化之旅 | 京东云技术团队

当项目的SQL查询慢得像蜗牛爬行时&#xff0c;用户的耐心也在一点点被消耗&#xff0c;作为研发&#xff0c;我们可不想看到这样的事。这篇文章将结合行云部署项目的实践经验&#xff0c;带你走进SQL优化的奇妙世界&#xff0c;一起探索如何让那些龟速的查询飞起来&#xff01;…

使用Redhat操作系统下载MySQL

一、本地下载安装 方法一 ①在虚拟机火狐浏览器中搜索MySQL官网&#xff08;选择第一个下载&#xff09; ②下载完毕使用xshell远程连接解压及安装 [rootlocalhost ~]# cd /Downloads/ [rootlocalhost Downloads]# mkdir /mysql/ [rootlocalhost Downloads]# mv mysql-8.0.3…

北斗短报文技术在灾区通讯救援中的应用与价值

北斗短报文技术在灾区通讯救援中的应用与价值 随着全球化的进程和科技的快速发展&#xff0c;人类社会在取得巨大经济成果的同时&#xff0c;也面临了许多自然灾害的挑战。地震、洪水、台风等天灾频繁发生&#xff0c;严重威胁着人们的生命财产安全。灾害发生时&#xff0c;及…

视频AI智剪方法:快速批量处理视频,批量剪辑视频的操作

随着科技的飞速发展&#xff0c;视频内容已是获取信息和娱乐的主要方式之一。对于视频创作者和内容生产者来说&#xff0c;如何快速、高效地处理和剪辑大量视频已成为一项重要的需求。现在借助AI技术的不断发展&#xff0c;可以更加智能、高效的处理视频。下面来看云炫AI智剪如…

深度学习:图神经网络——在推荐系统中的应用

PinSage是工业界应用图神经网络完成推荐任务的第一个成功案例&#xff0c;其从用户数据中构造图&#xff08;graph&#xff09;的方法和应对大规模图而采取的实现技巧都值得我们学习。PinSage被应用在图片推荐类Pinterest上。在Pinterest中&#xff0c;每个用户可以创建并命名图…

【angular教程240105】02绑定属性 绑定数据、条件判断、加载图片、【ngClass】 【ngStyle】、Angular管道

【angular】02绑定属性 绑定数据、条件判断、加载图片、【ngClass】 【ngStyle】、Angular管道 0 一些基础的概念 标记为可注入的服务 在Angular中&#xff0c;一个服务是一个通常提供特定功能的类&#xff0c;比如获取数据、日志记录或者业务逻辑等。标记为可注入的服务意味着…

推荐 5 款强大好用的日志管理工具

日志管理是现代 IT 环境中不可或缺的一部分&#xff0c;它有助于监视和维护应用程序、系统和网络的正常运行&#xff0c;帮助诊断问题&#xff0c;追踪事件以及确保安全性。 在日志管理领域&#xff0c;有不少功能强大的工具&#xff0c;本文将为你介绍这些工具。 1、Graylog …

Vue2:通过ref获取DOM元素

一、场景描述 我们在页面的开发过程中&#xff0c;经常需要操作dom元素&#xff0c;来实现我们需要的效果。 以往js中&#xff0c;我们是通过给dom添加id&#xff0c;然后&#xff0c;通过js代码document来获取这个dom 简写代码案例&#xff1a; <h2 id"test"&…

Mysql之子查询、连接查询(内外)以及分页查询

目录 一.案例&#xff08;接上篇博客&#xff09; 09&#xff09;查询学过「张三」老师授课的同学的信息 10&#xff09;查询没有学全所有课程的同学的信息 11&#xff09;查询没学过"张三"老师讲授的任一门课程的学生姓名 12&#xff09;查询两门及其以上不及格课程…

【数据结构】栈的基本知识详解

栈的基本概念与基本操作 导言一、栈的基本概念1.1 栈的定义1.2 栈的重要术语1.3 栈的数学性质 二、栈的基本操作结语 导言 大家好&#xff0c;很高兴又和大家见面了&#xff01;&#xff01;&#xff01; 今天开始&#xff0c;咱们将正式进入【数据结构】第三章的内容介绍。在…

第二证券:主力为什么要砸盘?

砸盘就是在股票的某个阶段有许多卖出单&#xff0c;这些许多的卖出单不断的成交使股票价格出现快速下跌。一般是受到主力资金洗盘或者出货所影响形成的。 1、洗盘 个股通过长时间上涨之后&#xff0c;盘中的散户较多&#xff0c;主力为了洗掉盘中的散户&#xff0c;在低位吸筹…

nodejs+vue+ElementUi音乐分享社交网站77l8j

本文介绍的系统主要分为两个部分&#xff1a;一是前台界面&#xff1a;用户通过注册登录可以实现音乐播放、新闻浏览、留言评论等功能&#xff1b;另一个是后台界面&#xff1a;音乐网站管理员对用户信息进行管理&#xff0c;上传更新音乐资源&#xff0c;发布最新音乐资讯等功…

SpringBoot 中 @Transactional 注解的使用

一、基本介绍 事务管理是应用系统开发中必不可少的一部分。Spring 为事务管理提供了丰富的功能支持。Spring 事务管理分为编程式和声明式的两种方式。本篇只说明声明式注解。 1、在 spring 项目中, Transactional 注解默认会回滚运行时异常及其子类&#xff0c;其它范…

目标检测再升级!YOLOv8模型训练和部署

YOLOv8 是 Ultralytics 开发的 YOLO&#xff08;You Only Look Once&#xff09;物体检测和图像分割模型的最新版本。YOLOv8是一种尖端的、最先进的SOTA模型&#xff0c;它建立在先前YOLO成功基础上&#xff0c;并引入了新功能和改进&#xff0c;以进一步提升性能和灵活性。它可…

揭秘阿里自研搜索引擎 Havenask 在线检索服务

作者&#xff1a;谷深 Havenask 是阿里巴巴智能引擎事业部自研的开源高性能搜索引擎&#xff0c;深度支持了包括淘宝、天猫、菜鸟、高德、饿了么在内几乎整个阿里的搜索业务。本文针对性介绍了 Havenask 的在线服务&#xff0c;它具备高可用、高时效、低成本的优势&#xff0c;…

【软考中级-软件设计师】day4:数据结构-线性表、单链表、栈和队列、串

大纲 线性结构 顺序存储和链式存储区别 单链表的插入和删除 真题 栈和队列 真题 串

微创新与稳定性的权衡

之前做过一个项目&#xff0c;业务最高峰CPU使用率也才50%&#xff0c;是一个IO密集型的应用。里面涉及一些业务编排&#xff0c;所以为了提高CPU使用率&#xff0c;我有两个方案&#xff1a;一个是简单的梳理将任务可并行的采用并行流、额外线程池等方式做并行&#xff1b;另外…

2019年认证杯SPSSPRO杯数学建模A题(第一阶段)好风凭借力,送我上青云全过程文档及程序

2019年认证杯SPSSPRO杯数学建模 纸飞机在飞行状态下的运动模型 A题 好风凭借力&#xff0c;送我上青云 原题再现&#xff1a; 纸飞机有许多种折法。世界上有若干具有一定影响力的纸飞机比赛&#xff0c;通常的参赛规定是使用一张特定规格的纸&#xff0c;例如 A4 大小的纸张…

计操进程同步(信号量pv灵魂三问法狂练版)

文章目录 解题秘诀-灵魂三问法一 同步问题1.1 围棋问题1.2 数据采集问题1.3 三进程文件打印问题1.4 司机售票员问题 二 同步互斥问题2.1 果盘问题 三 同步资源管控问题3.1 兔子问题3.2 数据写入和读取问题3.3 图书馆问题3.4 超市问题3.4.1 解法一3.4.2 解法二 解题秘诀-灵魂三问…

(Matlab)基于CNN-Bi_LSTM的多维时序回归预测(卷积神经网络-双向长短期记忆网络)

目录 一、程序及算法内容介绍&#xff1a; 基本内容&#xff1a; 亮点与优势&#xff1a; 二、实际运行效果&#xff1a; 三、部分代码展示&#xff1a; 四、完整代码数据下载&#xff1a; 一、程序及算法内容介绍&#xff1a; 基本内容&#xff1a; 本代码基于Matlab平…