Harbor

Harbor

无论是使用Docker-distribution去自建仓库,还是通过官方镜像跑容器的方式去自建仓库,通过前面的演示我们可以发现其是非常的简陋的,还不如直接使用官方的Docker Hub去管理镜像来得方便,至少官方的Docker Hub能够通过web界面来管理镜像,还能在web界面执行搜索,还能基于Dockerfile利用Webhooks和Automated Builds实现自动构建镜像的功能,用户不需要在本地执行docker build,而是把所有build上下文的文件作为一个仓库推送到github上,让Docker Hub可以从github上去pull这些文件来完成自动构建。

但无论官方的Docker Hub有多强大,它毕竟是在国外,所以速度是最大的瓶颈,我们很多时候是不可能去考虑使用官方的仓库的,但是上面说的两种自建仓库方式又十分简陋,不便管理,所以后来就出现了一个被 CNCF 组织青睐的项目,其名为Harbor。

Harbor简介

虽然Docker官方提供了公共的镜像仓库,但是从安全和效率等方面考虑,部署我们私有环境内的Registry也是非常必要的。

Harbor是由VMware公司开源的企业级的Docker Registry管理项目,相比docker官方拥有更丰富的权限权利和完善的架构设计,适用大规模docker集群部署提供仓库服务。

它主要提供 Dcoker Registry 管理界面UI,可基于角色访问控制,镜像复制, AD/LDAP 集成,日志审核等功能,完全的支持中文。

harbor的功能

Feathers:

  • 多租户内容签名和验证
  • 安全性和漏洞分析
  • 审核日志记录
  • 身份集成和基于角色的访问控制
  • 实例之间的映像复制
  • 可扩展的 API 和图形用户界面
  • 国际化(目前为中英文)

Harbor 部署

环境说明:

主机名 ip地址 需要安装的应用
docker 192.168.111.152 docekr-ce
harbor 192.168.111.151 docker-ce
docker-compose
Harbor

harbor主机操作

# 关闭防火墙和selinux
[root@harbor ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@harbor ~]# vi /etc/selinux/config
SELINUX=disabled
[root@harbor ~]# setenforce 0
[root@harbor ~]# reboot

# 配置docker-ce源
[root@harbor yum.repos.d]# curl -o docker-ce.repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --  0     0    0     0    0     0      0      0 --:--:--  0100  1919  100  1919    0     0   1265      0  0:00:01  0:00:01 --:--:--  1265
[root@harbor yum.repos.d]# sed -i 's@https://download.docker.com@https://mirrors.tuna.tsinghua.edu.cn/docker-ce@g' docker-ce.repo

# 安装 docker-ce
[root@harbor ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
[root@harbor ~]# yum -y install docker-ce --allowerasing

# 安装完成后,使用 docker version 命令查看docker的版本信息
[root@harbor ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:45:22 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

# 配置镜像加速
[root@harbor ~]# mkdir -p /etc/docker
[root@harbor ~]# vi /etc/docker/daemon.json
{
    "registry-mirrors": ["https://gpdm6wat.mirror.aliyuncs.com"]
}
[root@harbor ~]# systemctl daemon-reload
[root@harbor ~]# systemctl enable --now  docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

# 安装compose 和 harbor
[root@harbor ~]# curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --100   664  100   664    0     0   2128      0 --:--:-- --:--:-- --:--:--  2128
  0 12.1M    0  4233    0     0   2772      0  1:16:34  0  4 12.1M    4  568k    0     0   309k      0  0:00:40  0 50 12.1M   50 6248k    0     0  2201k      0  0:00:05  0 92 12.1M   92 11.1M    0     0  2987k      0  0:00:04  0100 12.1M  100 12.1M    0     0  3098k      0  0:00:04  0:00:04 --:--:-- 4995k
[root@harbor ~]# chmod +x /usr/local/bin/docker-compose
[root@harbor ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c

[root@harbor ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.111.151 harbor.example.com

[root@harbor ~]# ping harbor.example.com
PING harbor.example.com (192.168.111.151) 56(84) bytes of data.
64 bytes from harbor.example.com (192.168.111.151): icmp_seq=1 ttl=64 time=0.039 ms
64 bytes from harbor.example.com (192.168.111.151): icmp_seq=2 ttl=64 time=0.060 ms
64 bytes from harbor.example.com (192.168.111.151): icmp_seq=3 ttl=64 time=0.131 ms
^C
--- harbor.example.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2032ms
rtt min/avg/max/mdev = 0.039/0.076/0.131/0.040 ms

# 解压harbor包,查看install.sh脚本 和 xxx-compose.yml
[root@harbor ~]# cd /usr/src/
[root@harbor src]# ls
debug  harbor-offline-installer-v2.3.5.tgz  kernels
[root@harbor src]# tar xf harbor-offline-installer-v2.3.5.tgz -C /usr/local/
[root@harbor src]# cd /usr/local/harbor/
[root@harbor harbor]# ls
common.sh             harbor.yml.tmpl  LICENSE
harbor.v2.3.5.tar.gz  install.sh       prepare

# 对harbor配置文件进行修改
# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值