harbor仓库部署

2022/8/11 23:26:56

本文主要是介绍harbor仓库部署,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

harbor仓库部署

目录
  • harbor仓库部署
    • 部署条件
    • 部署harbor

Harbor简介

Harbor是由VMWare在Docker Registry的基础之上进行了二次封装,加进去了很多额外程序,而且提供了一个非常漂亮的web界面。

‎Project Harbor 是一个开源的可信云原生注册表项目,用于存储、签名和扫描上下文。‎

‎Harbor 通过添加用户通常需要的功能(如安全性、身份和管理)来扩展开源 Docker 分发版。‎

‎Harbor 支持高级功能,如用户管理、访问控制、活动监控和实例间复制‎.

Harbor的功能

‎羽毛:‎

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

Docker compose

Harbor在物理机上部署是非常难的,而为了简化Harbor的应用,Harbor官方直接把Harbor做成了在容器中运行的应用,而且这个容器在Harbor中依赖类似redis、mysql、pgsql等很多存储系统,所以它需要编排很多容器协同起来工作,因此VMWare Harbor在部署和使用时,需要借助于Docker的单机编排工具(Docker compose)来实现。

‎Compose 是用于定义和运行多容器 Docker 应用程序的工具。使用 Compose,您可以使用 YAML 文件来配置应用程序的服务。然后,使用单个命令,从配置中创建并启动所有服务。‎

Docker Compose官方文档

Harbor官方文档

部署条件

需要安装docker,有docker-compose命令

安装docker

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
[[email protected] yum.repos.d]# sed -i '[email protected]://[email protected]://mirrors.tuna.tsinghua.edu.cn/[email protected]' docker-ce.repo
[[email protected] yum.repos.d]# dnf -y install docker-ce

配置镜像加速器

[[email protected] ~]# sudo mkdir -p /etc/docker
[[email protected] ~]# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://w673ojdv.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://w673ojdv.mirror.aliyuncs.com"]
}
[[email protected] ~]# sudo systemctl daemon-reload
[[email protected] ~]# sudo systemctl restart docker
[[email protected] ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

安装docker-compose

//修改名字
[[email protected] ~]# hostnamectl set-hostname harbor.example.com
[r[email protected] ~]# bash
[[email protected] ~]# hostname
harbor.example.com

//安装docker-compose命令
[[email protected] ~]# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .config  .cshrc  .tcshrc  .viminfo  .wget-hsts  anaconda-ks.cfg
[[email protected] ~]# DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}	//创建一个.docker目录
[[email protected] ~]# mkdir -p $DOCKER_CONFIG/cli-plugins		//创建一个cli-plugins目录
[[email protected] ~]# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .config  .cshrc  .docker  .tcshrc  .viminfo  .wget-hsts  anaconda-ks.cfg
[[email protected] ~]# cd .docker/
[[email protected] .docker]# ls
cli-plugins
[[email protected] .docker]# curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose		//docker-compose下载路径

//已经下载好的上传至root下
[[email protected] ~]# ls
anaconda-ks.cfg  docker-compose-linux-x86_64.octet-stream
[[email protected] ~]# mv docker-compose-linux-x86_64.octet-stream /root/.docker/cli-plugins/docker-compose

//配置docker-compose
[[email protected] ~]# cd /root/.docker/cli-plugins/
[[email protected] cli-plugins]# ls
docker-compose
[[email protected] cli-plugins]# chmod +x docker-compose 
[[email protected] cli-plugins]# ll
total 25188
-rwxr-xr-x. 1 root root 25792512 Aug 11 18:31 docker-compose
[[email protected] cli-plugins]# ./docker-compose 		//可以使用了
[[email protected] cli-plugins]# pwd
/root/.docker/cli-plugins		//目前只能在文件夹里使用
[[email protected] cli-plugins]# ln -s /root/.docker/cli-plugins/docker-compose /usr/bin/		//创建软链接
[[email protected] cli-plugins]# cd 
[[email protected] ~]# which docker-compose
/usr/bin/docker-compose
[[email protected] ~]# docker compose version
Docker Compose version v2.7.0

部署harbor

安装harbor

[[email protected] ~]# wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz

//已经下载好的上传至root下
[[email protected] ~]# ls
anaconda-ks.cfg  harbor-offline-installer-v2.5.3.tgz
[[email protected] ~]# tar xf harbor-offline-installer-v2.5.3.tgz -C /usr/local/

//配置harbor
[[email protected] ~]# cd /usr/local/
[[email protected] local]# ls
bin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src
[[email protected] local]# cd harbor/
[[email protected] harbor]# ls
LICENSE  common.sh  harbor.v2.5.3.tar.gz  harbor.yml.tmpl  install.sh  prepare
[[email protected] harbor]# cp harbor.yml.tmpl harbor.yml
[[email protected] harbor]# vim harbor.yml
hostname: harbor.example.com		//修改为域名或者IP

#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		//注释掉
[[email protected] harbor]# ./install.sh 		//拉取镜像
[+] Running 10/10
 ⠿ Network harbor_harbor        Created                                                                                                     0.2s
 ⠿ Container harbor-log         Started                                                                                                     0.5s
 ⠿ Container registryctl        Started                                                                                                     2.0s
 ⠿ Container registry           Started                                                                                                     2.0s
 ⠿ Container redis              Started                                                                                                     2.1s
 ⠿ Container harbor-db          Started                                                                                                     2.0s
 ⠿ Container harbor-portal      Started                                                                                                     1.6s
 ⠿ Container harbor-core        Started                                                                                                     2.4s
 ⠿ Container nginx              Started                                                                                                     3.2s
 ⠿ Container harbor-jobservice  Started                                                                                                     3.2s
✔ ----Harbor has been installed and started successfully.----
[[email protected] harbor]# ss -anlt
State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port          Process           
LISTEN           0                128                            127.0.0.1:1514                          0.0.0.0:*                               
LISTEN           0                128                              0.0.0.0:22                            0.0.0.0:*                               
LISTEN           0                128                              0.0.0.0:443                           0.0.0.0:*                               
LISTEN           0                128                                 [::]:22                               [::]:*                               
LISTEN           0                128                                 [::]:443                              [::]:*                               

访问测试

image

image

设置开机自启动

[[email protected] harbor]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED         STATUS                   PORTS                                   NAMES
39dd86d1eec2   goharbor/harbor-jobservice:v2.5.3    "/harbor/entrypoint.…"   3 minutes ago   Up 3 minutes (healthy)                                           harbor-jobservice
71bf08bfd7da   goharbor/nginx-photon:v2.5.3         "nginx -g 'daemon of…"   3 minutes ago   Up 3 minutes (healthy)   0.0.0.0:80->8080/tcp, :::80->8080/tcp   nginx
61c050421868   goharbor/harbor-core:v2.5.3          "/harbor/entrypoint.…"   3 minutes ago   Up 3 minutes (healthy)                                           harbor-core
664cf7c60665   goharbor/redis-photon:v2.5.3         "redis-server /etc/r…"   3 minutes ago   Up 3 minutes (healthy)                                           redis
60a295df8091   goharbor/registry-photon:v2.5.3      "/home/harbor/entryp…"   3 minutes ago   Up 3 minutes (healthy)                                           registry
37374fefa729   goharbor/harbor-portal:v2.5.3        "nginx -g 'daemon of…"   3 minutes ago   Up 3 minutes (healthy)                                           harbor-portal
8530ed5fdee7   goharbor/harbor-db:v2.5.3            "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes (healthy)                                           harbor-db
a1741a70ff7d   goharbor/harbor-registryctl:v2.5.3   "/home/harbor/start.…"   3 minutes ago   Up 3 minutes (healthy)                                           registryctl
5d7a2d387ec8   goharbor/harbor-log:v2.5.3           "/bin/sh -c /usr/loc…"   3 minutes ago   Up 3 minutes (healthy)   127.0.0.1:1514->10514/tcp               harbor-log

//创建脚本进行自启动
[[email protected] ~]# vim /etc/rc.local 
#!/bin/bash						//开头位置
cd /usr/lcoal/harbor			//添加
docker-compose start			//添加
[[email protected] ~]# ll /etc/rc.d/rc.local 
-rw-r--r--. 1 root root 517 Aug 11 19:26 /etc/rc.d/rc.local
[[email protected] ~]# chmod +x /etc/rc.d/rc.local 

//重启查看是否开机自启动
[[email protected] ~]# reboot
[[email protected] ~]# ss -anlt
State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port          Process           
LISTEN           0                128                            127.0.0.1:1514                          0.0.0.0:*                               
LISTEN           0                128                              0.0.0.0:80                            0.0.0.0:*                               
LISTEN           0                128                              0.0.0.0:22                            0.0.0.0:*                               
LISTEN           0                128                                 [::]:80                               [::]:*                               
LISTEN           0                128                                 [::]:22                               [::]:*                               
[[email protected] ~]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED         STATUS                             PORTS                                   NAMES
39dd86d1eec2   goharbor/harbor-jobservice:v2.5.3    "/harbor/entrypoint.…"   5 minutes ago   Up 10 seconds (health: starting)                                           harbor-jobservice
71bf08bfd7da   goharbor/nginx-photon:v2.5.3         "nginx -g 'daemon of…"   5 minutes ago   Up 10 seconds (health: starting)   0.0.0.0:80->8080/tcp, :::80->8080/tcp   nginx
61c050421868   goharbor/harbor-core:v2.5.3          "/harbor/entrypoint.…"   5 minutes ago   Up 12 seconds (health: starting)                                           harbor-core
664cf7c60665   goharbor/redis-photon:v2.5.3         "redis-server /etc/r…"   5 minutes ago   Up 11 seconds (health: starting)                                           redis
60a295df8091   goharbor/registry-photon:v2.5.3      "/home/harbor/entryp…"   5 minutes ago   Up 11 seconds (health: starting)                                           registry
37374fefa729   goharbor/harbor-portal:v2.5.3        "nginx -g 'daemon of…"   5 minutes ago   Up 11 seconds (health: starting)                                           harbor-portal
8530ed5fdee7   goharbor/harbor-db:v2.5.3            "/docker-entrypoint.…"   5 minutes ago   Up 12 seconds (health: starting)                                           harbor-db
a1741a70ff7d   goharbor/harbor-registryctl:v2.5.3   "/home/harbor/start.…"   5 minutes ago   Up 11 seconds (health: starting)                                           registryctl
5d7a2d387ec8   goharbor/harbor-log:v2.5.3           "/bin/sh -c /usr/loc…"   5 minutes ago   Up 12 seconds (health: starting)   127.0.0.1:1514->10514/tcp               harbor-log


这篇关于harbor仓库部署的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程