其他分享
首页 > 其他分享> > harbor仓库部署

harbor仓库部署

作者:互联网

harbor仓库部署

目录

Harbor简介

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

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

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

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

Harbor的功能

‎羽毛:‎

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

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
[root@localhost yum.repos.d]# sed -i 's@https://download.docker.com@https://mirrors.tuna.tsinghua.edu.cn/docker-ce@g' docker-ce.repo
[root@localhost yum.repos.d]# dnf -y install docker-ce

配置镜像加速器

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

安装docker-compose

//修改名字
[root@harbor ~]# hostnamectl set-hostname harbor.example.com
[root@harbor ~]# bash
[root@harbor ~]# hostname
harbor.example.com

//安装docker-compose命令
[root@harbor ~]# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .config  .cshrc  .tcshrc  .viminfo  .wget-hsts  anaconda-ks.cfg
[root@harbor ~]# DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}	//创建一个.docker目录
[root@harbor ~]# mkdir -p $DOCKER_CONFIG/cli-plugins		//创建一个cli-plugins目录
[root@harbor ~]# ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .config  .cshrc  .docker  .tcshrc  .viminfo  .wget-hsts  anaconda-ks.cfg
[root@harbor ~]# cd .docker/
[root@harbor .docker]# ls
cli-plugins
[root@harbor .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下
[root@harbor ~]# ls
anaconda-ks.cfg  docker-compose-linux-x86_64.octet-stream
[root@harbor ~]# mv docker-compose-linux-x86_64.octet-stream /root/.docker/cli-plugins/docker-compose

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

部署harbor

安装harbor

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

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

//配置harbor
[root@harbor ~]# cd /usr/local/
[root@harbor local]# ls
bin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src
[root@harbor local]# cd harbor/
[root@harbor harbor]# ls
LICENSE  common.sh  harbor.v2.5.3.tar.gz  harbor.yml.tmpl  install.sh  prepare
[root@harbor harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor 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		//注释掉
[root@harbor 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.----
[root@harbor 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

设置开机自启动

[root@harbor 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

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

//重启查看是否开机自启动
[root@harbor ~]# reboot
[root@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: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                               [::]:*                               
[root@harbor ~]# 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,root,v2.5,仓库,部署,0.0,docker,minutes
来源: https://www.cnblogs.com/Their-own/p/16577761.html