Harbor企业镜像仓库部署(本地)

news2024/10/6 10:31:16

简述:

Docker 官方镜像仓库是用于管理公共镜像的地方,大家可以在上面找到想要的镜像,也可以把自己的镜像推送上去。但是有时候服务器无法访问互联网,或者不希望将自己的镜像放到互联网上,那么就需要用到 Docker Registry 私有仓库,它可以用来存储和管理自己的镜像。最近公司将项目全部打包成镜像有部署私有仓库服务的需求,经过几轮商讨,最终选择 Docker Harbor,Docker Harbor 有可视化的 Web 管理界面可以方便管理Docker 镜像操作也很方便简单,又提供了多个项目的镜像权限管理控制功能等。

Harbor 架构构成

  1. Proxy:Harbor 的 Registry、UI、token 等服务。通过一个前置的反向代理统一接收浏览器Docker 客户端的请求,并将请求转发给后端不同的服务。
  2. Registry:负责储存Docker镜像,并处理 Docker push/pull 命令。由于要对用户进行访问控制,即不同用户对Docker image有不同的读写权限,Registry会指向一个 token服务,强制用户的每次 Docker pull/push 请求都要携带一个合法的token,Registry会通过公钥对 token 进行解密验证。

环境:

两台主机:

192.168.50.66      master        服务端

192.168.50.53      lbin-nfs       客户端

两台主机同样操作

关闭防火墙

[root@localhost ~]# iptables -F

[root@localhost ~]# setenforce 0

[root@localhost ~]# systemctl stop firewalld

更改主机名

[root@localhost ~]# hostname master

[root@localhost ~]# bash

创建dockers  rpm包目录

[root@master ~]# mkdir docker

导入docker -ce

[root@master docker]# ll

总用量 97596

-rw-r--r--. 1 root root 30374084 9月  18 2020 containerd.io-1.3.7-3.1.el7.x86_64.rpm

-rw-r--r--. 1 root root    40816 7月   6 2020 container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm

-rw-r--r--. 1 root root   302564 5月  14 2020 device-mapper-1.02.164-7.el7_8.2.x86_64.rpm

-rw-r--r--. 1 root root   195448 5月  14 2020 device-mapper-event-1.02.164-7.el7_8.2.x86_64.rpm

-rw-r--r--. 1 root root   195004 5月  14 2020 device-mapper-event-libs-1.02.164-7.el7_8.2.x86_64.rpm

-rw-r--r--. 1 root root   331908 5月  14 2020 device-mapper-libs-1.02.164-7.el7_8.2.x86_64.rpm

-rw-r--r--. 1 root root   432624 4月   4 2020 device-mapper-persistent-data-0.8.5-2.el7.x86_64.rpm

-rw-r--r--. 1 root root 25268380 9月  18 2020 docker-ce-19.03.13-3.el7.x86_64.rpm

-rw-r--r--. 1 root root 40247476 10月  9 2020 docker-ce-cli-19.03.13-3.el7.x86_64.rpm

-rw-r--r--. 1 root root  1384208 5月  14 2020 lvm2-2.02.186-7.el7_8.2.x86_64.rpm

-rw-r--r--. 1 root root  1143916 5月  14 2020 lvm2-libs-2.02.186-7.el7_8.2.x86_64.rpm

[root@localhost docker]# yum -y install *.rpm

[root@localhost docker]# cd

重启

[root@localhost ~]#  systemctl start docker

[root@localhost ~]#  systemctl enable docker

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

配置阿里云镜像加速

[root@localhost ~]#  cat << END > /etc/docker/daemon.json

> {

>         "registry-mirrors":[ "https://nyakyfun.mirror.aliyuncs.com" ]

> }

> END

重启服务

 

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl restart docker

获取Docker Compose容器的工具。

[root@localhost ~]# rz

[root@localhost ~]# mv docker-compose /usr/bin

[root@localhost ~]#  chmod +x /usr/bin/docker-compose

[root@localhost ~]# docker-compose --version

docker-compose version 1.21.1, build 5a3f1a3

Harbor配置   服务端

 

[root@master ~]# tar xf harbor-offline-installer-v1.6.1.tgz

[root@master ~]# cd harbor

[root@master harbor]# tree

bash: tree: 未找到命令

[root@master harbor]# yum -y install tree

[root@master harbor]# tree ha
ha
├── docker-compose.clair.tpl
├── docker-compose.clair.yml
├── docker-compose.tpl
├── docker-compose.yml
├── initial-registry.sql
└── sample
    ├── active_active
    │   ├── check.sh
    │   └── keepalived_active_active.conf
    └── active_standby
        ├── check_harbor.sh
        └── keepalived_active_standby.conf

[root@master ]#  vim /root/harbor/harbor.cfg

 7 hostname = 192.168.50.66

[root@master harbor]#  sh install.sh

如果报错就更改下面文件

[root@master harbor]# cat ha/initial-registry.sql

CREATE DATABASE IF NOT EXISTS `registry` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';

成功

 查看

[root@master harbor]# docker-compose ps

       Name                     Command                  State                    Ports             

----------------------------------------------------------------------------------------------------

harbor-adminserver   /harbor/start.sh                 Up (healthy)                                  

harbor-db            /entrypoint.sh postgres          Up (healthy)   5432/tcp                       

harbor-jobservice    /harbor/start.sh                 Up                                            

harbor-log           /bin/sh -c /usr/local/bin/ ...   Up (healthy)   127.0.0.1:1514->10514/tcp      

harbor-ui            /harbor/start.sh                 Up (healthy)                                  

nginx                nginx -g daemon off;             Up (healthy)   0.0.0.0:443->443/tcp,          

                                                                     0.0.0.0:4443->4443/tcp,        

                                                                     0.0.0.0:80->80/tcp             

redis                docker-entrypoint.sh redis ...   Up             6379/tcp                       

registry             /entrypoint.sh /etc/regist ...   Up (healthy)   5000/tcp  

浏览器访问

如果一切都正常,应该可以打开浏览器访问192.168.50.66的管理页面,默认的管理员用户名和密码是 admin/Harbor12345

创建一个新项目

  1. 输入用户名和密码登录界面后可以创建一个新项目。点击“+项目”按钮。

 

 点击“确定”按钮,成功创建

 

 可以使用 Docker 命令在Harbor本地通过 127.0.0.1 来登录和推送镜像了。默认情况下, Register 服务器在端口 80 上

登陆 harbor

[root@master harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1

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@master harbor]# docker pull cirros

Using default tag: latest

latest: Pulling from library/cirros

d0b405be7a32: Pull complete

bd054094a037: Pull complete

c6a00de1ec8a: Pull complete

Digest: sha256:1e695eb2772a2b511ccab70091962d1efb9501fdca804eb1d52d21c0933e7f47

Status: Downloaded newer image for cirros:latest

docker.io/library/cirros:latest

给镜像打tag

[root@master harbor]# docker tag cirros 127.0.0.1/cccoooo/cirros:v1

上传到 harbor

[root@master harbor]# docker push 127.0.0.1/cccoooo/cirros:v1

The push refers to repository [127.0.0.1/cccoooo/cirros]

984ad441ec3d: Pushed

f0a496d92efa: Pushed

e52d19c3bee2: Pushed

v1: digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22 size: 943

查看一下有没有

[root@master harbor]# docker images

REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE

127.0.0.1/cccoooo/cirros        v1                  f9cae1daf5f6        2 years ago         12.6MB

刷新查看

客户端上传镜像

 修改配置文件

 vim /usr/lib/systemd/system/docker.service

 14 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock  --insecure-reg istry192.168.50.66

重启服务

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl restart docker

登陆访问

第一种

[root@lbin-nfs ~]#  docker login -u admin -p Harbor12345 http://192.168.50.66

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@lbin-nfs ~]# docker login -u admin -p Harbor12345 192.168.50.66

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@lbin-nfs ~]# docker pull cirros

Using default tag: latest

latest: Pulling from library/cirros

d0b405be7a32: Pull complete

bd054094a037: Pull complete

c6a00de1ec8a: Pull complete

Digest: sha256:1e695eb2772a2b511ccab70091962d1efb9501fdca804eb1d52d21c0933e7f47

Status: Downloaded newer image for cirros:latest

docker.io/library/cirros:latest

打标签

[root@lbin-nfs ~]# docker tag cirros 192.168.50.66/cccoooo/cirros:v22

上传

[root@lbin-nfs ~]# docker push 192.168.50.66/cccoooo/cirros:v22

The push refers to repository [192.168.50.66/cccoooo/cirros]

984ad441ec3d: Layer already exists

f0a496d92efa: Layer already exists

e52d19c3bee2: Layer already exists

v22: digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22 size: 943

浏览器查看

 Harbor 日常操作管理

点击“+项目”时按规范填写项目名称。项目级别:私有即不勾选(勾选后会变为"公开")。如果设置为公共仓库,则所有人对此项目下的镜像拥有读权限,命令行中不需要执行"Docker login"即可下载镜像,镜像操作与Docker hub 一致。

创建用户

 

设置权限

 首先退出当前用户,然后使用上述创建的账户 登录。

退出

[root@lbin-nfs ~]#  docker logout 192.168.50.66

Removing login credentials for 192.168.50.66

登陆

[root@lbin-nfs ~]# docker login 192.168.50.66

Username: asd

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/#credentials-store

Login Succeeded

下载v1镜像

[root@lbin-nfs ~]# docker pull 192.168.50.66/cccoooo/cirros:v1

Error response from daemon: pull access denied for 192.168.50.66/cccoooo/cirros, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

[root@lbin-nfs ~]# docker pull 192.168.50.66/cccoooo/cirros:v1

v1: Pulling from cccoooo/cirros

Digest: sha256:483f15ac97d03dc3d4dcf79cf71ded2e099cf76c340f3fdd0b3670a40a198a22

Status: Downloaded newer image for 192.168.50.66/cccoooo/cirros:v1

192.168.50.66/cccoooo/cirros:v1

查看

[root@lbin-nfs ~]# docker images

REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE

postgres                       latest              07e2ee723e2d        19 months ago       374MB

mysql                          5.6                 dd3b2a5dcb48        19 months ago       303MB

redis                          alpine              3900abf41552        20 months ago       32.4MB

192.168.50.66/cccoooo/cirros   v1                  f9cae1daf5f6        2 years ago         12.6MB

 查看日志

 

管理 Harbor

可以使用 docker-compose来管理Harbor。一些有用的命令如下所示(必须在与docker-compose.yml 相同的目录中运行)。

停止/启动/重启 Harbor

[root@master harbor]#  docker-compose stop | start | restart

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

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

相关文章

Docker desktop使用配置

1. 下载安装 https://www.docker.com/ 官网下载并安装doker desktop 2. 配置镜像 &#xff08;1&#xff09;首先去阿里云网站上进行注册&#xff1a;https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors &#xff08;2&#xff09;注册完成后搜索&#xff1a;容…

用 docker 创建 jmeter 容器,能做性能测试?

我们都知道&#xff0c;jmeter 可以做接口测试&#xff0c;也可以用于性能测试&#xff0c;现在企业中性能测试也大多使用 jmeter。docker 是最近这些年流行起来的容器部署工具&#xff0c;可以创建一个容器&#xff0c;然后把项目放到容器中&#xff0c;就可以构建出一个独立的…

独立站私域怎么玩?浅浅了解一下吧!

当你是一个跨境电商独立站的卖家&#xff0c;你的工作有三个主要焦点&#xff1a;充分利用流量、提升用户转化率和降低用户的总体成本。 然而&#xff0c;除了利用广告以外&#xff0c;是否有更多的策略可以帮助你接触到用户&#xff0c;同时降低吸引新用户的成本呢&#xff1…

LeetCode150道面试经典题-合并两个有序数组(简单)

合并两个有序数组 题目&#xff1a; 给你两个按 非递减顺序 排列的整数数组 nums1 和 nums2&#xff0c;另有两个整数 m 和 n &#xff0c;分别表示 nums1 和 nums2 中的元素数目。 请你 合并 nums2 到 nums1 中&#xff0c;使合并后的数组同样按 非递减顺序 排列。 注意&a…

每天一道leetcode:剑指 Offer 11. 旋转数组的最小数字(适合初学者)

今日份题目&#xff1a; 把一个数组最开始的若干个元素搬到数组的末尾&#xff0c;我们称之为数组的旋转。 给你一个可能存在 重复 元素值的数组 numbers &#xff0c;它原来是一个升序排列的数组&#xff0c;并按上述情形进行了一次旋转。请返回旋转数组的最小元素。例如&am…

前端页面性能优化,性能测试算法优化,MeterSphere开源持续测试平台v2.10.5 LTS版本发布

2023年8月7日&#xff0c;MeterSphere一站式开源持续测试平台正式发布v2.10.5 LTS版本。自2023年5月发布v2.10 LTS版本后&#xff0c;MeterSphere开源项目组坚持每两周发布小版本&#xff0c;持续进行问题的修复更新&#xff0c;并针对部分功能进行优化。 本次发布的MeterSphe…

【深度学习】采用自动编码器生成新图像

一、说明 你知道什么会很酷吗&#xff1f;如果我们不需要所有这些标记的数据来训练 我们的模型。我的意思是标记和分类数据需要太多的工作。 不幸的是&#xff0c;大多数现有模型从支持向量机到卷积神经网&#xff0c;没有它们&#xff0c;卷积神经网络就无法训练。无监督学习不…

7月27日上课内容 Firewalld防火墙

iptables 软件防火墙 包过滤防火墙firewalld 防火墙包过滤防火墙。网络层centos7自带的默认的防火墙。取代iptables firewalld两种配置模式 运行时配置 永久配置 iptables是静态防火墙 firewalld是动态防火墙。 firewalld安装区域来进行划分: 9个区域 moba里面要打开防火墙 fi…

智慧工厂解决方案[60页PPT]

导读&#xff1a;原文《》&#xff08;获取来源见文尾&#xff09;&#xff0c;本文精选其中精华及架构部分&#xff0c;逻辑清晰、内容完整&#xff0c;为快速形成售前方案提供参考。 完整版领取方式 完整版领取方式&#xff1a; 如需获取完整的电子版内容参考学习 您可以关注…

OpenCv.js(图像处理)学习历程

opencv.js官网 4.5.0文档 以下内容整理于opencv.js官网。 简介 OpenCV由Gary Bradski于1999年在英特尔创建。第一次发行是在2000年。OpenCV支持c、Python、Java等多种编程语言&#xff0c;支持Windows、Linux、Os X、Android、iOS等平台。基于CUDA和OpenCL的高速GPU操作接口也…

【Seata1.5.2 下载 配置 整合 踩坑 测试】—— 含各种踩坑记录(详细版)

&#x1f4a7; S e a t a 1.5.2 ——含各种踩坑记录 \color{#FF1493}{Seata1.5.2 —— 含各种踩坑记录} Seata1.5.2——含各种踩坑记录&#x1f4a7; &#x1f337; 仰望天空&#xff0c;妳我亦是行人.✨ &#x1f984; 个人主页——微风撞见云的博客&#x1f390; &…

KM生存分析

这个系列从2022年开始&#xff0c;一直更新使用R语言分析数据及绘制精美图形。小杜的生信笔记主要分享小杜学习日常&#xff01;如果&#xff0c;你对此感兴趣可以加入该系列的学习。 最终图形 本期图形代码 ##KM生存分析 ##20230807##导入包 library(survival) library(surv…

【深度学习】StyleGANv2 2019 论文,Analyzing and Improving the Image Quality of StyleGAN

StyleGAN论文&#xff1a; 《A Style-Based Generator Architecture for Generative Adversarial Networks》 论文&#xff1a;https://arxiv.org/abs/1812.04948 代码&#xff1a; https://github.com/NVlabs/stylegan StyleGANv2论文&#xff1a; 《Analyzing and Improving …

Linux葵花宝典-无需自宫版

1. Linux简介 1.1 什么是Linux Linux&#xff0c;全称GNU/Linux&#xff0c;是一种免费使用和自由传播的类UNIX操作系统&#xff0c;其内核由Linus Torvalds于1991年10月5日首次发布&#xff0c;它主要受到Minix和Unix思想的启发&#xff0c;是一个基于POSIX的多用户、多任务、…

【知网检索稳定】第八届现代管理和教育技术国际学术会议(MMET2023)

第八届现代管理和教育技术国际学术会议&#xff08;MMET 2023&#xff09;将于2023年09月22-24日在中国上海召开。会议由四川大学、泰国程逸皇家大学、泰国程逸皇家大学中泰同文同学国际交流中心主办、乐山师范学院、四川职业技术学院、AEIC学术交流中心协办。会议主要围绕会议…

边写代码边学习之numpy

1. numpy.matmul() 用法 matmul() 用于计算两个数组的矩阵乘积。示例如下 def matmul_test():array1 np.array([[[1.0, 3], [1, 1], [2, 3]]])array2 np.array([[2, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0],[1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0], ])result np.matmul(array1, …

C语言有关文件的操作

打开文件与关闭文件 在编写代码时&#xff0c;我有一个习惯是“保证一一对应”。 写下代码fopen()之后&#xff0c;还没有写对文件进行增删查改等操作的代码&#xff0c;先立刻写上fclose()&#xff0c;避免忘记关闭FILE* fd的情况。 不关闭fd&#xff0c;在fopen()次数较少的…

linux初始命令

如果没有ip地址&#xff0c;配置&#xff1a; 查看当前时间&#xff1a; 指定格式查看时间&#xff1a; 修改时间&#xff1a; 查看时区&#xff1a; 设置时区&#xff1a; 查看当前工作目录&#xff1a; root的家目录就是根&#xff0c;普通用户家目录是home

迈瑞BeneVision N17/N15/N12协议解析

迈瑞BeneVision N17/N15/N12协议解析

pdf 怎么转换成word 文档?这几种方法不容错过

pdf 怎么转换成word 文档&#xff1f;PDF 和 Word 都是日常工作和学习中常见的文档格式&#xff0c;但是它们拥有不同的特点。PDF 可以保持文档格式的一致性&#xff0c;并且不易修改&#xff0c;而 Word 则更加灵活&#xff0c;可以随意编辑和修改。因此&#xff0c;将 PDF 转…