Harbor安装及简单使用

在虚拟机初始化的基础上

安装Docker

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

yum -y install docker-ce

systemctl enable docker && systemctl start docker

配置镜像下载加速器:

cat > /etc/docker/daemon.json << EOF

{

  "registry-mirrors": ["https://b9pmyelo.mirror.aliyuncs.com"],

  "insecure-registries": ["http://192.168.20.160:801"

}

EOF

systemctl restart docker

安装Docker-compose(需要挂加速器)

[root@harbor ~]# wget -c  https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-x86_64

[root@harbor ~]# mv docker-compose-Linux-x86_64  /usr/bin/docker-compose

[root@harbor ~]# chmod  a+x /usr/bin/docker-compose

[root@harbor ~]# docker-compose  --version

docker-compose version 1.25.5, build 8a1c60f6

下载harbor离线安装包并解压

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

[root@harbor ~]# tar -xf harbor-offline-installer-v2.0.0.tgz

 cd harbor

 cp harbor.yml.tmpl  harbor.yml

# mkdir -p /opt/application/harbor     //用于存放harbor的持久化数据

harbor.yml配置文件主要修改参数如下:

5 hostname: 192.168.20.160

#//设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost。默认情况下,harbor使用的端口是80,若使用自定义的端口,除了要改docker-compose.yml文件中的配置外,这里的hostname也要加上自定义的端口,否则在docker login、push时会报错

10   port: 801

34 harbor_admin_password: yuguoli12345

#https配置(如不需要可不配置,注释掉)

 12 # https related config

 13 #https:

 14   # https port for harbor, default is 443

 15  # port: 443

 16   # The path of cert and key files for nginx

 17   #certificate: /your/certificate/path

 18   #private_key: /your/private/key/path

29   # external_url: https://reg.mydomain.com:8433

# //如果要启用外部代理,比如外层的NGINX、LB等,请取消注释external_url,当它启用时,hostname将不再使用。

34 harbor_admin_password: admin密码

#//admin密码

#数据库配置

 37 database:

 38   # The password for the root user of Harbor DB. Change this before any produ    ction use.

 39   password: root123

 40   # The maximum number of connections in the idle connection pool. If it <=0,     no idle connections are retained.

 41   max_idle_conns: 50

 42   # The maximum number of open connections to the database. If it <= 0, then     there is no limit on the number of open connections.

 43   # Note: the default number of connections is 100 for postgres.

 44   max_open_conns: 100

#持久化数据目录

47 data_volume: /opt/application/harbor

创建 https 证书

# 创建证书目录,并赋予权限

[root@harbor ~]# mkdir  /https/ca  -p

[root@harbor ~]# chmod  -R 777 /https/ca/

[root@harbor ~]# cd /https/ca/

# 生成私钥,需要设置密码:1234

[root@harbor ca]# openssl genrsa -des3 -out harbor.key 2048

Generating RSA private key, 2048 bit long modulus

.........+++

..................................+++

e is 65537 (0x10001)

Enter pass phrase for harbor.key:1234

Verifying - Enter pass phrase for harbor.key:1234

# 生成CA证书,需要输入密码1234

[root@harbor ca]# openssl req -sha512 -new \

>     -subj "/C=CN/ST=JS/L=WX/O=zwx/OU=jhmy/CN=10.0.0.28" \

>     -key harbor.key \

>     -out harbor.csr

Enter pass phrase for harbor.key:1234

# 备份证书

[root@harbor ca]# cp harbor.key  harbor.key.org

# 退掉私钥密码,以便docker访问(也可以参考官方进行双向认证)

[root@harbor ca]# openssl rsa -in harbor.key.org -out harbor.key

Enter pass phrase for harbor.key.org:1234

writing RSA key

# 使用证书进行签名

[root@harbor ca]# openssl x509 -req -days 100000  -in harbor.csr -signkey harbor.key -out harbor.crt

Signature ok

subject=/C=CN/ST=JS/L=WX/O=zwx/OU=jhmy/CN=10.0.0.28

Getting Private key

[root@harbor ~]# cd  harbor/

[root@harbor harbor]# vim  harbor.yml

https:

  # https port for harbor, default is 443

  port: 443

  # The path of cert and key files for nginx

  certificate: /https/ca/harbor.crt

  private_key: /https/ca/harbor.key

安装并启动Harbor

安装之前需要启动docker,然后执行安装脚本:

--with-clair参数是启用漏洞扫描功能

[root@harbor harbor]# ./root/harbor/install.sh  --with-clair

 浏览器访问 

http://IP:801

 

先创建用户

创建项目

给项目加入用户,设置角色

 查看推送命令

 

# 给镜像打上标签

- 镜像仓库地址/项目名称/标签信息

docker tag nginx:1.16 IP:801/user001/nginx:1.16.1

服务器主机要对镜像进行操作必须先登录!!!

# 登录仓库

docker login http://IP:801

#退出登录

docker logout https://IP:801

推送镜像

docker push IP:801/user001/nginx:1.16.1

拉取镜像

docker pull IP:801/user001/nginx:1.16.1

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
想要进行Harbor离线安装,你需要进行以下步骤: 1. 下载Harbor离线安装包:你可以从Harbor的官方网站(https://github.com/goharbor/harbor/releases)上下载最新版本的Harbor离线安装包。选择适合你系统的版本(Linux或Windows)以及对应的Harbor版本。 2. 安装Docker:在安装Harbor之前,你需要先安装Docker。如果你已经安装Docker,请确保它是最新版本。 3. 解压Harbor离线安装包:将下载的Harbor离线安装包解压到你想要安装的目录。 4. 修改配置文件:在解压后的目录中,找到并打开“harbor.yml”文件。根据你的需要,修改其中的配置参数,例如端口号、存储路径、证书等。 5. 执行安装脚本:打开终端或命令行界面,进入Harbor解压后的目录,并执行以下命令: ``` sudo ./install.sh --with-notary --with-trivy ``` 这个命令将会安装Harbor,并且同时安装Notary和Trivy。如果你不需要Notary和Trivy,可以将"--with-notary"和"--with-trivy"从命令中删除。 6. 等待安装完成:在执行安装脚本后,等待一段时间,直到安装完成。你可以在终端或命令行界面中看到安装进度和日志信息。 7. 验证安装结果:在安装完成后,你可以使用浏览器访问Harbor的Web界面,验证是否安装成功。 这是一个简单Harbor离线安装过程,具体步骤可能会因为不同的环境而有所不同。如果你遇到了问题,可以参考Harbor的官方文档或者社区论坛,寻求帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值