Install Harbor 2.8 on Centos

2023-11-16

目录

Node & System/Software Lists

Architecture Overview of Harbor

Install Harbor 2.8

Harbor Installation Prerequisites

Install Docker and Docker Compose

Install Harbor

Pull and Push image from Harbor

Reference documentation 


Node & System/Software Lists

HOSTNAME

IP NODE TYPE CONFIG
master1 192.168.1.100 harbor server 4vCPU4G
System Version

kernel
3.10.0-1160.el7.x86_64
centos CentOS Linux release 7.9.2009 (Core)
Software Name Version
docker 24.0.2
docker compose v2.18.1
harbor v2.8.1

Architecture Overview of Harbor

With Harbor V2.0, users can manage images, manifest lists, Helm charts, CNABs, OPAs among others which all adhere to the OCI image specification.You can read more here[1].

Install Harbor 2.8

Here we start to install Harbor 2.8 on the target host.following below steps and get Harold installed:

  1. Harbor Installation Prerequisites
  2. Install Docker and Docker Compose
  3. Install Harbor
  4. Pull and Push image from Harbor

Harbor Installation Prerequisites

Harbor is deployed as several Docker containers. You can therefore deploy it on any Linux distribution that supports Docker. The target host requires Hardware,Software,Network ports show like below.

Hardware

Resource Minimum Recommended
CPU 2 CPU 4 CPU
Mem 4 GB 8 GB
Disk 40 GB 160 GB

Software 

Software Version Description
Docker Engine Version 17.06.0-ce+ or higher For installation instructions, see Docker Engine documentation
Docker Compose docker-compose (v1.18.0+) or docker compose v2 (docker-compose-plugin) For installation instructions, see Docker Compose documentation
OpenSSL Latest is preferred Used to generate certificate and keys for Harbor

Network ports

Port Protocol Description
443 HTTPS Harbor portal and core API accept HTTPS requests on this port.
4443 HTTPS Connections to the Docker Content Trust service for Harbor. Only required if Notary is enabled. 
80 HTTP Harbor portal and core API accept HTTP requests on this port. 

Install Docker and Docker Compose

You can copy and run all there shell commands and get docker components and docker-compose:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl start docker
sudo systemctl enable docker
sudo wget https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64
sudo mv docker-compose-linux-x86_64 /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose

Install Harbor

Copying and running all the bellow shells:

mkdir ~/harbor && cd ~/harbor
wget https://github.com/goharbor/harbor/releases/download/v2.8.1/harbor-offline-installer-v2.8.1.tgz
tar zxf harbor-offline-installer-v2.8.1.tgz-C /usr/local/

The harbor.yml.tmpl in this folder and we need copy and turn to harbor.yml which is harbor server read this name by default.Replace the hostname and comment out the https line temporary.Then run `./install.sh` to install harbor. 

[root@master1 harbor]# ls
common.sh  harbor.v2.8.1.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@master1 harbor]# cp harbor.yml.tmpl harbor.yml
[root@master1 harbor]# vim harbor.yml
..........
hostname: harbor_node01.example.com		//Replace hostname to your hostip or hostname
.........
#https:									//Comment out the https line
  # 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
.........

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

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

Note: docker version: 24.0.2

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

Note: Docker Compose version v2.18.1

[Step 2]: loading Harbor images ...
Loaded image: goharbor/registry-photon:v2.8.1
Loaded image: goharbor/notary-server-photon:v2.8.1
Loaded image: goharbor/harbor-core:v2.8.1
Loaded image: goharbor/harbor-jobservice:v2.8.1
Loaded image: goharbor/harbor-exporter:v2.8.1
Loaded image: goharbor/trivy-adapter-photon:v2.8.1
Loaded image: goharbor/prepare:v2.8.1
Loaded image: goharbor/redis-photon:v2.8.1
Loaded image: goharbor/nginx-photon:v2.8.1
Loaded image: goharbor/notary-signer-photon:v2.8.1
Loaded image: goharbor/harbor-portal:v2.8.1
Loaded image: goharbor/harbor-log:v2.8.1
Loaded image: goharbor/harbor-db:v2.8.1
Loaded image: goharbor/harbor-registryctl:v2.8.1


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
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 ...
[+] Building 0.0s (0/0)                                                                                                                                                                     
[+] Running 10/10
 ✔ Network harbor_harbor        Created                                                                                                                                                0.1s 
 ✔ Container harbor-log         Started                                                                                                                                                1.7s 
 ✔ Container registryctl        Started                                                                                                                                                2.1s 
 ✔ Container harbor-portal      Started                                                                                                                                                2.8s 
 ✔ Container registry           Started                                                                                                                                                2.8s 
 ✔ Container harbor-db          Started                                                                                                                                                2.8s 
 ✔ Container redis              Started                                                                                                                                                2.8s 
 ✔ Container harbor-core        Started                                                                                                                                                3.6s 
 ✔ Container harbor-jobservice  Started                                                                                                                                                5.1s 
 ✔ Container nginx              Started                                                                                                                                                5.1s 
✔ ----Harbor has been installed and started successfully.----

Note: After updating harbor.yml,running the prepare script to populate the configuration.And 

vim harbor.yml
sudo ./prepare
sudo docker-compose up -d

To reconfigure Harbor to install Notary and Trivy, include all of the components in the prepare command. 

sudo ./prepare --with-notary --with-trivy

 We use docker-compose to manage harbor like bellow. For more enter `docker-compose --help`

[root@master1 harbor]# docker-compose ls
NAME                STATUS              CONFIG FILES
harbor              running(9)          /usr/local/harbor/docker-compose.yml
[root@master1 harbor]# docker-compose ps
NAME                IMAGE                                COMMAND                  SERVICE             CREATED             STATUS                    PORTS
harbor-core         goharbor/harbor-core:v2.8.1          "/harbor/entrypoint.…"   core                22 hours ago        Up 11 minutes (healthy)   
harbor-db           goharbor/harbor-db:v2.8.1            "/docker-entrypoint.…"   postgresql          22 hours ago        Up 11 minutes (healthy)   
harbor-jobservice   goharbor/harbor-jobservice:v2.8.1    "/harbor/entrypoint.…"   jobservice          22 hours ago        Up 11 minutes (healthy)   
harbor-log          goharbor/harbor-log:v2.8.1           "/bin/sh -c /usr/loc…"   log                 22 hours ago        Up 11 minutes (healthy)   127.0.0.1:1514->10514/tcp
harbor-portal       goharbor/harbor-portal:v2.8.1        "nginx -g 'daemon of…"   portal              22 hours ago        Up 11 minutes (healthy)   
nginx               goharbor/nginx-photon:v2.8.1         "nginx -g 'daemon of…"   proxy               22 hours ago        Up 11 minutes (healthy)   0.0.0.0:80->8080/tcp, :::80->8080/tcp
redis               goharbor/redis-photon:v2.8.1         "redis-server /etc/r…"   redis               22 hours ago        Up 11 minutes (healthy)   
registry            goharbor/registry-photon:v2.8.1      "/home/harbor/entryp…"   registry            22 hours ago        Up 11 minutes (healthy)   
registryctl         goharbor/harbor-registryctl:v2.8.1   "/home/harbor/start.…"   registryctl         22 hours ago        Up 11 minutes (healthy)   
[root@master1 harbor]# docker-compose images
CONTAINER           REPOSITORY                    TAG                 IMAGE ID            SIZE
harbor-core         goharbor/harbor-core          v2.8.1              075ed731ac18        165MB
harbor-db           goharbor/harbor-db            v2.8.1              01ca249e7dc2        174MB
harbor-jobservice   goharbor/harbor-jobservice    v2.8.1              977ee6bff288        141MB
harbor-log          goharbor/harbor-log           v2.8.1              145a69b937ca        134MB
harbor-portal       goharbor/harbor-portal        v2.8.1              6c2b21221aca        134MB
nginx               goharbor/nginx-photon         v2.8.1              cea1bb2450ee        127MB
redis               goharbor/redis-photon         v2.8.1              cb8b735b33ba        128MB
registry            goharbor/registry-photon      v2.8.1              c125efcb6c2a        79.1MB
registryctl         goharbor/harbor-registryctl   v2.8.1              c141d82ffd0a        141MB
[root@master1 harbor]# docker-compose stop
[+] Stopping 9/9
 ✔ Container nginx              Stopped                                                                                                                                                0.7s 
 ✔ Container harbor-jobservice  Stopped                                                                                                                                                0.6s 
 ✔ Container registryctl        Stopped                                                                                                                                               10.3s 
 ✔ Container harbor-portal      Stopped                                                                                                                                                0.3s 
 ✔ Container harbor-core        Stopped                                                                                                                                                0.2s 
 ✔ Container harbor-db          Stopped                                                                                                                                                0.3s 
 ✔ Container registry           Stopped                                                                                                                                                0.3s 
 ✔ Container redis              Stopped                                                                                                                                                0.3s 
 ✔ Container harbor-log         Stopped                                                                                                                                               10.2s 
[root@master1 harbor]# docker-compose start
[+] Running 9/9
 ✔ Container harbor-log         Started                                                                                                                                                0.6s 
 ✔ Container harbor-portal      Started                                                                                                                                                0.8s 
 ✔ Container registryctl        Started                                                                                                                                                1.1s 
 ✔ Container redis              Started                                                                                                                                                0.7s 
 ✔ Container harbor-db          Started                                                                                                                                                0.9s 
 ✔ Container registry           Started                                                                                                                                                0.9s 
 ✔ Container harbor-core        Started                                                                                                                                                0.4s 
 ✔ Container harbor-jobservice  Started                                                                                                                                                0.7s 
 ✔ Container nginx              Started                                                                                                                                                0.8s 

Use the browser to enter "http://hostip:80"(for me is http://192.168.1.100:80 to access it.

The default username and password are admin/Harbor12345

Pull and Push image from Harbor

Push

 Push an image refer three steps:

  1. set docker-harbor insecure-registary(or set .cert file)
  2. docker login harbor (required this login user have push permissions)
  3. docker tag and docker push(tag format like harbor-host:ip/project name/imagename:v)

Here is a sample of push a image named busybox:latest. 

[root@localhost ~]# vim /etc/docker/daemon.json
{
  "insecure-registries": ["192.168.1.100:80","0.0.0.0"]
}
[root@master1 harbor]# docker pull busybox:latest
[root@master1 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
busybox                         latest    8135583d97fe   12 days ago   4.86MB
[root@master1 harbor]# docker tag busybox:latest 192.168.1.100:80/library/busybox:v0.1
[root@master1 harbor]# docker images
REPOSITORY                         TAG       IMAGE ID       CREATED       SIZE
192.168.1.100:80/library/busybox   v0.1      8135583d97fe   12 days ago   4.86MB
busybox                            latest    8135583d97fe   12 days ago   4.86MB
[root@master1 harbor]# docker login -u admin -p Harbor12345 http://192.168.1.100:80
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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/#credentials-store

Login Succeeded
[root@master1 harbor]# docker push 192.168.1.100:80/library/busybox:v0.1
The push refers to repository [192.168.1.100:80/library/busybox]
9547b4c33213: Pushed 
v0.1: digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43 size: 528

Pull 

 Pull an image refer three steps:

  1. set docker-harbor insecure-registary(or set .cert file)
  2. docker login harbor(required this login user have pull permissions)
  3. docker pull

Here are two methods to pull an imgae from Harbor.One is set configuration of "registry-mirrors' and pull an image via unfull name which means no need to enter all addresses and specify labels.Two is pull an image via specify image name and tag.

//method1:
[root@master1 harbor]# vim /etc/docker/daemon.json
{
 "registry-mirrors": ["http://192.168.1.100:80"],
 "insecure-registries": ["192.168.1.100:80","0.0.0.0"]
}

[root@master1 harbor]# docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
325d69979d33: Pull complete 
Digest: sha256:560af6915bfc8d7630e50e212e08242d37b63bd5c1ccf9bd4acccf116e262d5b
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest
//or
[root@master1 harbor]# docker pull busybox:v0.1
v0.1: Pulling from library/busybox
Digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43
Status: Downloaded newer image for busybox:v0.1
docker.io/library/busybox:v0.1


//method2:
[root@master1 harbor]# docker pull 192.168.1.100:80/library/busybox:v0.1
v0.1: Pulling from library/busybox
325d69979d33: Pull complete 
Digest: sha256:5cd3db04b8be5773388576a83177aff4f40a03457a63855f4b9cbe30542b9a43
Status: Downloaded newer image for 192.168.1.100:80/library/busybox:v0.1
192.168.1.100:80/library/busybox:v0.1

 You can copy command to get image address like below:

Delete 

Login into harbor-webui and operate it if you want delete image.

Reference documentation 

[1] Architecture Overview of Harbor · goharbor/harbor Wiki · GitHub

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Install Harbor 2.8 on Centos 的相关文章

随机推荐

  • springmvc进阶(3):mvc:annotation-driven和mvc:default-servlet-handler在springmvc中的作用

    在springmvc xml中 经常会配置
  • 2036: [蓝桥杯2022初赛] 统计子矩阵(二维前缀和,一维前缀和)

    2036 蓝桥杯2022初赛 统计子矩阵 内存限制 256 MB 时间限制 1 S 标准输入输出 题目类型 传统 评测方式 文本比较 上传者 外部导入 提交 310 通过 74 题目描述 给定一个 N M 的矩阵A 请你统计有多少个子矩阵
  • linux安装mysql

    安装环境 工具 1 Linux CentOS 7 4版 2 mysql 8 0 12 el7 x86 64 tar gz 安装步骤 参考 https dev mysql com doc refman 8 0 en installing ht
  • 【满分】【华为OD机试真题2023 JS】寻找相似单词

    华为OD机试真题 2023年度机试题库全覆盖 刷题指南点这里 寻找相似单词 知识点字符串排序 时间限制 1s 空间限制 256MB 限定语言 不限 题目描述 给定一个可存储若干单词的字典 找出指定单词的所有相似单词 并且按照单词名称从小到大
  • 人工智能-马尔可夫模型

    马尔可夫与马尔科夫都可以 所以也别纠结 马尔可夫模型 Markov Model 是一种统计模型 广泛应用在语音识别 词性自动标注 音字转换 概率文法等各个自然语言处理等应用领域 经过长期发展 尤其是在语音识别中的成功应用 使它成为一种通用的
  • java.util.LinkedHashMap cannot be cast to com.XXX.XXX

    ResquestBody的HashMap转List时错误java util LinkedHashMap cannot be cast to com XXX XXX RequsetBody Map
  • 五个温度带的分界线_亚热带,暖温带,到底是些什么带?

    在地理课上 讲到有关气候的内容时 经常会提到各种 带 例如暖温带 中温带 寒温带 你能清晰地分清谁是谁吗 首先 我们先来澄清一个概念 温度带和热量带 很多人分不清这两个词 但实际上 它们的内在含义是大致相同的 但是如果细究 两者的划分方式是
  • 服务器间数据传输的四种方式

    scp 优点 简单方便 安全可靠 支持限速参数 缺点 不支持排除目录 用法 scp就是secure copy 是用来进行远程文件拷贝的 数据传输使用 ssh 并且和ssh 使用相同的认证方式 提供相同的安全保证 scp 参数 lt 源地址
  • cmake tutorial

    Tutorial 1 最基本的项目是从源代码构建可执行文件 对于简单的项目 三行CMakeLists txt足够了 这就是本教程的起点 在Step1目录下创建一个CMakeLists txt 如下所示 cmake minimum requi
  • 运行报错:from .qhull import * ImportError: DLL load failed: 找不到指定的模块。

    记录一次报错 当出现这个问题时说明模块安装有误 但不知道原因 应该是在此之前需要先把安装的numpy scipy sklearn卸载掉 先看究竟是哪个模块出的错误 直接 pip uninstall numpy pip uninstall s
  • Chatgpt 未来可以应用的场景

    ChatGPT是一款基于GPT 3的聊天机器人 它具有自然语言处理和生成语言的强大能力 在很多场景下可以有很广泛的应用 以下是ChatGPT未来可以应用的一些场景 客服 ChatGPT可以被用作客服机器人 为用户提供帮助和解答问题 教育 C
  • 坐上支付宝微信支付巨头的刷脸顺风车

    人脸识别技术已经在互联网 政务领域得到了广泛应用 超过100个城市的用户通过支付宝刷脸完成身份验证中国财政科学研究院应用学博士后盘和林认为 刷脸支付比密码支付更安全更便捷 随着门槛的进一步降低 刷脸支付或将在未来3年内呈现爆发式的增长 20
  • Pytorch 计算一个矩阵行向量之间的相似度

    import torch def similarity input tensor step 1 计算行向量的长度 len a torch sqrt torch sum input tensor 2 dim 1 b len a unsquee
  • Enum枚举类型实战总结,保证有用!

    一般在我们开发时如果能使用枚举罗列的 一般都会定义一个枚举类型 将枚举类型作为方法的参数 可以方便的进行调用 给我们带来不少的便利 当然有时候它还不如直接用一个int类型带来 带来一定灵活性 但只要能满足业务咱们就怎么方便怎么来吧 基本使用
  • Java+MyEclipse+Tomcat (二)配置Servlet及简单实现表单提交

    在Java EE应用编程中Servlet是基础 JSP是建立在Servlet基础之上的 其他Web框架如Struts WebWork和Spring MVC都是基于Servlet的 本文主要讲述MyEclipse和Tomcat配置Servle
  • MATLAB的KLT算法实现视频中人脸跟踪检测

    上次已经用卡尔曼滤波实现了人脸跟踪 也取得了一定的效果 但仍存在一些问题 如人侧脸的时候跟踪效果并不理想 而KLT算法则能很好的解决这个问题 本文一共两部分 理论部分借鉴博了客园上的博主 https www cnblogs com moon
  • JavaScript 类型判断 判断Null和Undefined

    js类型判断 判断Null和Undefined javaScript中判断数据类型的方法主要有三种 typeof 原理是通过根据变量的机器码来判断 instanceof 根据 构造函数的 prototype 属性是否出现在某个实例对象的原型
  • 如何使用宝塔面板搭建网站(最后一步!上传文件至宝塔面板)

    这里就是我们搭建宝塔面板的最后一步了 把我们的PHP文件上传到宝塔面板上 就可以通过因特尔网络访问我们的网址了 第一步 基础安装 必须是Linux服务器 不支持window服务器 最低要求配置1核1G当然再低些也能运行但是不建议 要求服务器
  • python入门爬虫实例(含代码)

    准备工作 1 导入requeste库 需要下载 2 获取url 3 查找User Agent 请求载体的身份标识符 把它当成headers 避免反爬 4 把获取到的的数据存储起来 import requests if name main u
  • Install Harbor 2.8 on Centos

    目录 Node System Software Lists Architecture Overview of Harbor Install Harbor 2 8 Harbor Installation Prerequisites Insta