Docker之jenkins部署harbor在harbor中完成部署

news2024/9/20 15:00:20

Docker之jenkins部署harbor在harbor中完成部署

1、harbor作用

Harbor允许用户用命令行工具对容器镜像及其他Artifact进行推送和拉取,并提供了图形管理界面帮助用户查阅和删除这些Artifact。在Harbor 2.0版本中,除容器镜像外,Harbor对符合OCI规范的Helm Chart、CNAB、OPA Bundle等都提供了更多的支持。另外,Harbor为管理员提供了丰富的管理功能,特别是作为开源软件,随着版本的迭代,很多社区用户的反馈和贡献被吸收进来以便更好地适应。

2、harbor下载

https://github.com/goharbor/harbor/releases/tag/v2.8.3

3、安装

将里面的harbor.yml.temp 复制一份变成harbor.yml文件,然后修改下面几个

# 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.
hostname: harbor.ycz.com # 这里改,之后在etc/host中新增

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 8000 # 这里改

# 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 

启动

sudo ./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.19.1

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


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /Users/mac/docker/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
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
loaded secret from file: /data/secret/keys/secretkey
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.1s 
 ✔ Container harbor-log         Started                                                                  0.7s 
 ✔ Container registryctl        Started                                                                  1.4s 
 ✔ Container harbor-portal      Started                                                                  1.5s 
 ✔ Container harbor-db          Started                                                                  1.5s 
 ✔ Container redis              Started                                                                  1.8s 
 ✔ Container registry           Started                                                                  1.8s 
 ✔ Container harbor-core        Started                                                                  2.0s 
 ✔ Container nginx              Started                                                                  2.5s 
 ✔ Container harbor-jobservice  Started                                                                  2.5s 
✔ ----Harbor has been installed and started successfully.----

4、访问

默认密码时 admin Harbor12345

在这里插入图片描述

5、新增一个仓库,随便取名字

在这里插入图片描述
在这里插入图片描述

6、docker随便弄一个镜像试试能不能上传到仓库上

将mytest的重命名了,命名方式为 harbor地址/项目名/镜像名:版本

macdeMacBook-Pro:harbor mac$ docker tag 84fd17f590f0 harbor.ycz.com:8000/repo/mytest:latest
macdeMacBook-Pro:harbor mac$ docker images
REPOSITORY                                                TAG                                                                          IMAGE ID       CREATED          SIZE
mytest                                                    latest                                                                       84fd17f590f0   32 minutes ago   558MB
harbor.ycz.com:8000/repo/mytest                           latest                                                                       84fd17f590f0   32 minutes ago   558MB

push上去,发现没有权限

macdeMacBook-Pro:~ mac$ docker push harbor.ycz.com:8000/repo/mytest:latest
The push refers to repository [harbor.ycz.com:8000/repo/mytest]
0eeca62d60e3: Preparing 
508262fdcf74: Preparing 
99417f399c4c: Preparing 
6b5aaff44254: Preparing 
53a0b163e995: Preparing 
b626401ef603: Waiting 
9b55156abf26: Waiting 
293d5db30c9f: Waiting 
03127cdb479b: Waiting 
9c742cd6c7a5: Waiting 
unauthorized: unauthorized to access repository: repo/mytest, action: push: unauthorized to access repository: repo/mytest, action: push

登陆之后再push

macdeMacBook-Pro:~ mac$ docker login -u admin -p Harbor12345 harbor.ycz.com:8000
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
macdeMacBook-Pro:~ mac$ docker push harbor.ycz.com:8000/repo/mytest:latest
The push refers to repository [harbor.ycz.com:8000/repo/mytest]
0eeca62d60e3: Pushed 
508262fdcf74: Pushed 
99417f399c4c: Pushed 
6b5aaff44254: Pushed 
53a0b163e995: Pushed 
b626401ef603: Pushed 
9b55156abf26: Pushed 
293d5db30c9f: Pushed 
03127cdb479b: Pushed 
9c742cd6c7a5: Pushed 
latest: digest: sha256:68fa7d0fef4a2c8286cf195a6a7566f58f86349c5e04829f84083feae31eee99 size: 2421

成功

在这里插入图片描述

将刚刚push之前的harbor.ycz.com:8000/repo/mytest:latest删了,之后再从repo中拉取试试看

macdeMacBook-Pro:~ mac$ docker pull harbor.ycz.com:8000/repo/mytest:latest
latest: Pulling from repo/mytest
Digest: sha256:68fa7d0fef4a2c8286cf195a6a7566f58f86349c5e04829f84083feae31eee99
Status: Downloaded newer image for harbor.ycz.com:8000/repo/mytest:latest
harbor.ycz.com:8000/repo/mytest:latest

What's Next?
  View summary of image vulnerabilities and recommendations → docker scout quickview harbor.ycz.com:8000/repo/mytest:latest

7、将原来的jenkins项目构建docker中改成这样

在这里插入图片描述

docker build -t mytest /var/jenkins_home/workspace/test
docker login -u admin -p Harbor12345 harbor.ycz.com:8000
docker tag mytest:latest harbor.ycz.com:8000/repo/mytest:latest
docker push harbor.ycz.com:8000/repo/mytest:latest

成功构建

在这里插入图片描述

成功push到harbor

在这里插入图片描述

8、需要在harbor服务器中编写docker构建的代码

  1. 告知服务器拉取哪个镜像
  2. 判断当前的服务器是否在进行,需要删除
  3. 如果目标服务器已经存在当前的镜像,需要删除
  4. 目标服务器拉取harbor上的镜像
  5. 将拉取下来的镜像运行成容器

vi deploy.sh

harbor_addr=$1
harbor_repo=$2
project=$3
version=$4
container_port=$5
host_port=$6

imageName=$harbor_addr/$harbor_repo/$project:$version

echo $imageName

containerId=`docker ps -a | grep ${project} | awk '{print $1}'`

echo $containerId

if [ "$containerId" != "" ] ; then
 docker stop $containerId
 docker rm $containerId
fi

tag=`docker images | grep ${project} | awk  '{print $2}'`

echo $tag

if [[ "$tag"  =~ "$version" ]] ; then
 docker rmi $imageName
fi

docker login -u admin -p Harbor12345 $harbor_addr

docker pull $imageName

docker run -d -p $host_port:$container_port --name $project $imageName

echo "SUCCESS"

9、jenkins构建

到这里修改目标的host

在这里插入图片描述

再修改jenkins的构建

在这里插入图片描述

![在这里插入图片描述](https://img-blog.csdnimg.cn/ccedeb6db6e646a5bceb580d7f742706.png在这里插入图片描述

成功

在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

自定义线程池 01 - 阻塞队列

完整代码已上传gitee ,地址 :朱元杰的开源仓库 – ThreadPool核心源码仿写 完整文章栏目地址在:Fearless____的博客 - ThreadPool仿写 接下来将手动仿写一个线程池,第一步先仿写 阻塞队列 ​​​​​​​​​​​​​​​​​ 为…

docker删除容器时报错:Error response from daemon: reference does not exist

前言 之前使用的docker版本太低了,升级高版本docker之后的错误。 低版本docker(1.30.1)中的镜像有:golang、mysql,将docker升级为24.0.5并新拉取mysql最新版本之后,执行docker images命令,发现…

【Kaggle】Identify Contrails to Reduce Global Warming 比赛数据集的可视化(含源代码)

一、数据简单解读 卫星图像最初来自&#xff1a; https://www.goes-r.gov/spacesegment/abi.html高级基线成像仪是GOES-R系列中用于对地球天气、海洋和环境进行成像的主要仪器。ABI用16个不同的光谱波段观察地球&#xff08;上一代GOES只有<>个&#xff09;&#xff0c…

MySQL数据库基础语法 - 上

一&#xff0c;数据库操作 数据库中不区分大小写&#xff01;&#xff01;&#xff01; 1.1 显示数据库 show databases ; 如图&#xff1a; 1.2 创建数据库 create database [ if not exists ]数据库名 ; 如图&#xff1a; 1.3 使用数据库 use 数据库名 &#xff1b; 如图&a…

PHP codeigniter4 搭配Nginx

> 主要是为了用Nginx运行PHP环境 1. Nginx 官方文档的配置 default.conf This configuration enables URLs without “index.php” in them and using CodeIgniter’s “404 - File Not Found” for URLs ending with “.php”. server {listen 80;listen [::]:80;se…

Discovery studio构建药效团(Pharmacophore)的方式

药效团(Pharmacophore)是特征化的三维结构要素的组合&#xff0c;可以分为两种类型。一类是具有相同药理作用的类似物&#xff0c;它们具有某种基本结构&#xff0c;即相同的化学结构部分如磺胺类药物、局麻药、受体阻断剂、拟肾上腺素药物等;另一类是一组化学结构完全不同的分…

快速上手Vue开发:新一代Vue官方脚手架(create-vue)

文章目录 一、简介二、创建一个 Vue 应用1、前提条件2、安装命令3、可选插件 一、简介 create-vue 是 Vue3 的专用脚手架&#xff0c;使用 vite 创建 Vue3 的项目&#xff0c;也可以选择安装需要的各种插件&#xff0c;使用更简单。 二、创建一个 Vue 应用 官网地址&#xff…

【云原生】Docker 详解(一):从虚拟机到容器

Docker 详解&#xff08;一&#xff09;&#xff1a;从虚拟机到容器 1.虚拟化 要解释清楚 Docker&#xff0c;首先要解释清楚 容器&#xff08;Container&#xff09;的概念。要解释容器的话&#xff0c;就需要从操作系统说起。操作系统太底层&#xff0c;细说的话一两本书都说…

.netcore grpc一元方法详解

一、grpc服务端搭建 打开visual studio--》新建项目--》创建ASP.NET Core gRPC服务。 这里我是用的.NET 6.0做为底层框架&#xff0c;使用该框架支持grpc的功能更全面。令注使用nuget包Grpc.AspNetCore这里我使用的是2.40.0版本。 // 创建dollar.proto文件syntax "prot…

【Linux的开胃小菜】Linux系统安装后初始化配置操作

我们刚接手一台刚安装好服务器系统之后&#xff0c;可以对系统进行一些基础优化&#xff1a; 常规设定&#xff1a; centos: 1.关闭 iptables 2.关闭 selinux 3.设定 ChronyUbuntu: 4. /etc/security/limits.conf 5. /etc/sysctl.conf1.首先使用国内阿里云的yum源&#xff08…

企业微信 企业内部开发 学习笔记

官方文档 文档 术语介绍 引入pom <dependency><groupId>com.github.binarywang</groupId><artifactId>wx-java-cp-spring-boot-starter</artifactId><version>4.5.3.B</version></dependency>核心代码 推送消息 final WxCp…

基于Crow的C++的WebSocket服务器

基于Crow的C的WebSocket服务器 一、WebSocket 1.1 什么是WebSocket WebSocket 是一种持久化的通讯协议。 很多网站为了实现推送技术&#xff0c;所用的技术都是轮询&#xff0c;这种解决方案是指由浏览器每隔一段时间向服务器发出 HTTP 请求&#xff0c;然后服务器返回最新的…

【BASH】回顾与知识点梳理(十七)

【BASH】回顾与知识点梳理 十七 十七. 什么是 Shell scripts17.1 干嘛学习 shell scripts自动化管理的重要依据追踪与管理系统的重要工作简单入侵检测功能连续指令单一化简易的数据处理跨平台支持与学习历程较短 17.2 第一支 script 的撰写与执行撰写第一支 script 17.3 撰写 s…

NACOS2.0本地单机版

问题 由于某些原因服务器上面的nacos临时不能使用了&#xff0c;需要开发每个人在本机搭个单机nacos进行调试开发。&#x1f611;一言难尽。 这里假设本机已经安装好Java8的环境了。 步骤 下载二进制包 直接跑到nacos的github项目页面下载就行了。 https://github.com/aliba…

Linux常用命令(一):创建文件目录

一、touch&#xff1a; 1、作用&#xff1a; 1). 改变已有文件的时间戳属性&#xff0c;修改文件时间戳时&#xff0c;用户必须的文件的属主&#xff0c;或者拥有写文件的权限 2). 创建新的空文件 2、语法&#xff1a; touch [option] 文件名 ,后面可跟多个文件名3、示例 …

企业权限管理(六)-订单详情

订单详情查询 跳转到订单详情页面orders-show.jsp <button type"button" class"btn bg-olive btn-xs" onclick"location.href${pageContext.request.contextPath}/orders/findById.do?id${orders.id}">详情</button>OrdersControl…

大数据Flink(五十九):Flink on Yarn的三种部署方式介绍以及注意

文章目录 Flink on Yarn的三种部署方式介绍以及注意 一、Pre-Job 模式部署作业

【Stable Diffusion】雨天、湿身

一、Models 1.1、Wet Clothes (Clothing Style) [LoHA] WECL SEE-THROUGH WET WET HAIR BIKINI OR SWIMSUIT UNDER CLOTHES NO BRA BRA VISIBLE THROUGH CLOTHES MISC SHIRTS MISC CLOTHES1.2、Rain 雨 Multiply Style rain style1.3、Wet T-Shirt LORA <lora:wetshirt:…

虹科方案 | 成都大运会进行时,保障大型活动无线电安全需要…

成都大运会 7月28日&#xff0c;备受关注的第31届世界大学生夏季运动会在成都正式开幕。据悉&#xff0c;这是全球首个5G加持的智慧大运会&#xff0c;也是众多成熟信息技术的综合“应用场”。使用基于5G三千兆、云网、8K超高清视频等技术&#xff0c;在比赛现场搭建多路8K摄像…

python的gui界面程序爬虫,python的gui界面怎么打开

大家好&#xff0c;小编来为大家解答以下问题&#xff0c;python的gui界面怎么打开&#xff0c;python的gui界面程序爬虫&#xff0c;今天让我们一起来看看吧&#xff01; Python支持多种图形界面的第三方库&#xff0c;包括&#xff1a; wxWidgets Qt GTK Tkinter&#xf…