Harbor部署与应用


Harbor部署

//安装docker-compose
[root@localhost ~]# DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
[root@localhost ~]# mkdir -p $DOCKER_CONFIG/cli-plugins
[root@localhost ~]# curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
[root@localhost ~]# cd .docker/cli-plugins/
[root@localhost cli-plugins]# ls
docker-compose
[root@localhost cli-plugins]# chmod +x docker-compose 
[root@localhost cli-plugins]# ll
total 25188
-rwxr-xr-x 1 root root 25792512 Aug 11 18:11 docker-compose
[root@localhost cli-plugins]# ln -s /root/.docker/cli-plugins/docker-compose /usr/bin/
[root@localhost ~]# which docker-compose
/usr/bin/docker-compose

//安装harbor
[root@localhost src]# wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz
[root@localhost src]# ls
harbor-offline-installer-v2.5.3.tgz
[root@localhost src]# tar xf harbor-offline-installer-v2.5.3.tgz -C /usr/local/

//部署harbor
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
apache  apr-util  etc    harbor   lib    libexec  php7  share
apr     bin       games  include  lib64  mysql    sbin  src
[root@localhost local]# cd harbor/
[root@localhost harbor]# ls
common.sh             harbor.yml.tmpl  LICENSE
harbor.v2.5.3.tar.gz  install.sh       prepare
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# ls
common.sh             harbor.yml       install.sh  prepare
harbor.v2.5.3.tar.gz  harbor.yml.tmpl  LICENSE

[root@localhost harbor]# hostnamectl set-hostname harbore.example.com
[root@localhost harbor]# bash
[root@harbore harbor]# hostname
harbore.example.com

[root@harbore harbor]# vim harbor.yml
hostname: harbore.example.com     //修改域名 
# https related config            //关于https的全部注释掉
#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@harbore harbor]# ./install.sh
[root@harbore 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@harbore ~]# vim /etc/rc.local 
#!/bin/bash 
cd /usr/local/harbor            //添加这二行
docker-compose start
[root@harbore ~]# ll /etc/rc.d/rc.local 
-rw-r--r--. 1 root root 516 Aug 12 03:16 /etc/rc.d/rc.local
[root@harbore ~]# chmod +x /etc/rc.d/rc.local 
[root@harbore ~]# ll /etc/rc.d/rc.local 
-rwxr-xr-x. 1 root root 516 Aug 12 03:16 /etc/rc.d/rc.local

使用IP登录管理Harbor:

harbor应用

//做ip映射
[root@zdz ~]# vim /etc/hosts
192.168.26.138 harbore.example.com
//编辑daemon.json文件
[root@zdz ~]# vim /etc/docker/daemon.json 
{
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/"],
    "insecure-registries": ["harbore.example.com"]
}
//在客户端登录harbor
[root@zdz ~]# docker login 192.168.26.138
Username: admin
Password: 
Error response from daemon: Get "https://192.168.26.138/v2/": dial tcp 192.168.26.138:443: connect: connection refused
[root@zdz ~]# docker login harbore.example.com
Username: admin
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

////将镜像上传到harbor仓库
[root@zdz ~]# docker tag zzking1/z1:v0.1 harbore.example.com/library/httpd:v0.1
[root@zdz ~]# docker push harbore.example.com/library/httpd:v0.1
The push refers to repository [harbore.example.com/library/httpd]
19ededa395d0: Pushed 
74ddd0ec08fa: Pushed 
v0.1: digest: sha256:483ad26ed2010cdd990ec202aeab3a79bb5e9a96f21fab00d3e6360bc8a15027 size: 742

去浏览器访问harbor仓库验证

posted @ 2022-08-11 19:21  世界的尽头*  阅读(90)  评论(0)    收藏  举报