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]# ls
docker-compose
[root@localhost cli-plugins]# pwd
/root/.docker/cli-plugins
[root@localhost cli-plugins]# ln -s /root/.docker/cli-plugins/docker-compose /usr/bin/
[root@localhost cli-plugins]# cd
[root@localhost ~]# which docker-compose
/usr/bin/docker-compose
[root@localhost ~]# docker-compose version
Docker Compose version v2.7.0


//下载Harbor仓库
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz

//解压到相应目录
[root@localhost ~]# cd /usr/local/src/
[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/
[root@localhost src]# cd /usr/local/
[root@localhost local]# ls
bin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd harbor/
[root@localhost harbor]# ls
common.sh  harbor.v2.5.3.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare

//修改主机名称
[root@localhost harbor]# hostnamectl set-hostname harbor.example.com
[root@localhost harbor]# bash

//修改配置文件
[root@harbor harbor]# ls
common.sh  harbor.v2.5.3.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@harbor harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor harbor]# ls
common.sh  harbor.v2.5.3.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@harbor harbor]# vim harbor.yml

# Configuration file of Harbor
  
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: harbor.example.com					修改主机名称

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

# 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
........
//安装harbor
[root@harbor harbor]# ./install.sh
安装过程......

//设置开机自启
[root@harbor harbor]# vim /etc/rc.local 
......
# that this script will be executed during boot.

touch /var/lock/subsys/local

cd /usr/local/harbor										添加这两行
docker-compose start

[root@harbor harbor]# ll /etc/rc.local 
lrwxrwxrwx. 1 root root 13 Dec  2  2020 /etc/rc.local -> rc.d/rc.local
[root@harbor harbor]# chmod +x /etc/rc.d/rc.local 
[root@harbor harbor]# ll /etc/rc.local 
lrwxrwxrwx. 1 root root 13 Dec  2  2020 /etc/rc.local -> rc.d/rc.local
[root@harbor ~]# reboot
[root@harbor ~]# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED          STATUS                    PORTS                                   NAMES
2b41fb0d21da   goharbor/harbor-jobservice:v2.5.3    "/harbor/entrypoint.…"   13 minutes ago   Up 56 seconds (healthy)                                           harbor-jobservice
.......

网页登录测试
在这里插入图片描述
在这里插入图片描述

Harpor仓库应用

增加一台主机 注意:需要安装docker

链接: Docker安装

//安装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]# ls
docker-compose
[root@localhost cli-plugins]# pwd
/root/.docker/cli-plugins
[root@localhost cli-plugins]# ln -s /root/.docker/cli-plugins/docker-compose /usr/bin/
[root@localhost cli-plugins]# cd
[root@localhost ~]# which docker-compose
/usr/bin/docker-compose
[root@localhost ~]# docker-compose version
Docker Compose version v2.7.0

//设置主机映射 进行测试
[root@localhost ~]# vim /etc/hosts
[root@localhost ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.182.128 harbor.example.com
[root@localhost ~]# ping -c 2 harbor.example.com
PING harbor.example.com (192.168.182.128) 56(84) bytes of data.
64 bytes from harbor.example.com (192.168.182.128): icmp_seq=1 ttl=64 time=0.734 ms
64 bytes from harbor.example.com (192.168.182.128): icmp_seq=2 ttl=64 time=0.988 ms

--- harbor.example.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 0.734/0.861/0.988/0.127 ms

// 登录仓库
///使用"insecure-registries"参数支持http的访问 
[root@localhost ~]# vim /etc/docker/daemon.json 
[root@localhost ~]# cat /etc/docker/daemon.json 
{
	  "registry-mirrors": ["https://e1nfzb1k.mirror.aliyuncs.com"],			//这里是阿里云的加速器地址
	    "insecure-registries": ["192.168.182.128"]									//这里跟harbor仓库IP
}
[root@localhost ~]# systemctl daemon-reload 
[root@localhost ~]# systemctl restart docker

//登录到harbor仓库
[root@localhost ~]# docker login 192.168.182.128
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

//修改镜像名称和标签 
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
httpd        latest    f2a976f932ec   11 days ago   145MB
[root@localhost ~]# docker tag httpd:latest 192.168.182.128/library/httpd:v0.1
[root@localhost ~]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
192.168.182.128/library/httpd   v0.1      f2a976f932ec   11 days ago   145MB
httpd                           latest    f2a976f932ec   11 days ago   145MB

//上传镜像
[root@localhost ~]# docker push 192.168.182.128/library/httpd:v0.1 
The push refers to repository [192.168.182.128/library/httpd]
0c2dead5c030: Pushed 
54fa52c69e00: Pushed 
28a53545632f: Pushed 
eea65516ea3b: Pushed 
92a4e8a3140f: Pushed 
v0.1: digest: sha256:98778663b10c3952e9d7dd8a10e1ca2a8ce31f11b5f0ff9d7b3b36ddb8201db8 size: 1366

在这里插入图片描述

其他的应用

创建系统账户
在这里插入图片描述
建立新的仓库
在这里插入图片描述
可以选择类型
在这里插入图片描述
当然还有其他的功能 比如创建标签 定义项目的定额

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值