惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
T
Threat Research - Cisco Blogs
V
Vulnerabilities – Threatpost
T
Tor Project blog
T
Troy Hunt's Blog
C
CERT Recently Published Vulnerability Notes
C
Cisco Blogs
W
WeLiveSecurity
Cloudbric
Cloudbric
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
爱范儿
爱范儿
Google Online Security Blog
Google Online Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Martin Fowler
Martin Fowler
Cisco Talos Blog
Cisco Talos Blog
F
Full Disclosure
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
I
Intezer
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
M
MIT News - Artificial intelligence
腾讯CDC
L
LangChain Blog
L
LINUX DO - 热门话题
H
Help Net Security
S
Schneier on Security
N
Netflix TechBlog - Medium
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
Spread Privacy
Spread Privacy
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
P
Privacy International News Feed
P
Privacy & Cybersecurity Law Blog
Cyberwarzone
Cyberwarzone
A
About on SuperTechFans
NISL@THU
NISL@THU
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
雷峰网
雷峰网
AWS News Blog
AWS News Blog
V2EX - 技术
V2EX - 技术

博客园 - 含羞草

Jenkins的pipeline脚本中获取git代码变更用户名和email CentOS7安装配置SonarQube Gitlab自动触发Jenkins构建项目 CentOS7安装Jenkins Master 解决win7下打开Excel2007,报“向程序发送命令时出现问题”的错误 转:老调重弹:const char*, char const* and char *const WebService:System.InvalidOperationException: 无法生成临时类 PowerBuilder:表中字段的数据长度的修改对数据窗口的影响 转:使用SET NOCOUNT优化存储过程 转:如何使用SQL Server 2005 专用管理员连接(DAC)登录到服务器 四遥量 VS.NET开发环境的WIN FORM中怎样加入ActiveX控件 C# Winform程序如何获取运行路径 转:类型"string"的值无法转换为"System.Drawing.Color" - 含羞草 - 博客园 转: Simple ASP.NET 2.0 Tips and Tricks that You May (or may not) have Heard About (一些简单的、你可能已经知道或者不知道的ASP.NET 2.0技巧) Asp.net : 访问嵌套模版页中的控件 SQL Server 2005 : 服务器不允许远程客户端登录的解决办法 SQL Server 2005 : 清空数据库日志 安装删除服务
CentOS安装Harbor
含羞草 · 2018-10-30 · via 博客园 - 含羞草

CentOS版本:7.4

Harbor版本:1.5.0

Docker版本:1.12.6

Docker Compose版本:1.21.2

一、安装Harbor(http方式,80端口)

1、安装Docker

(1)搜索docker

[root@node3 ~]# yum search docker

(2)安装docker

[root@node3 ~]# yum install -y docker

(3)启动命令

[root@node3 ~]# systemctl start docker

(4)查看状态

[root@node3 ~]# systemctl status docker

(5)查看版本

[root@node3 ~]# docker version

(6)查看docker信息

[root@node3 ~]# docker info

(7)开机启动

[root@node3 ~]# systemctl enable docker

2、安装Docker Compose

1)下载文件

curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

2)添加可执行权限

chmod +x /usr/local/bin/docker-compose

wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.0.tgz

4、解压Harbor离线安装文件

Harbor安装路径:/root/local/harbor

tar zxf harbor-offline-installer-v1.5.0.tgz -C /root/local

5、修改harbor.cfg

cd /root/local/harbor

vim harbor.cfg

修改hostname为本机IP地址

#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 = 10.72.77.176

6、执行准备命令

./prepare

7、执行安装命令

./install.sh

8、访问网址

http://10.72.77.176

二、安装Harbor(https方式,80端口)

1、停止第一步安装好的Harbor容器

docker-compose down -v

2、SSL证书配置

官网配置说明:

https://github.com/vmware/harbor/blob/master/docs/configure_https.md

(1)生成根证书

a. 创建证书存放目录

mkdir -p /data/cert && cd /data/cert

b. 创建自己的CA证书(不使用第三方权威机构的CA来认证,自己充当CA的角色)

openssl genrsa -out ca.key 2048   #生成根证书私钥(无加密)

openssl req -x509 -new -nodes -key ca.key -days 10000 -out ca.crt -subj "/CN=Harbor-sz"

req     产生证书签发申请命令

-x509   签发X.509格式证书命令。X.509是最通用的一种签名证书格式。

-new    生成证书请求-key     指定私钥文件-nodes   表示私钥不加密

-out    输出-subj    指定用户信息 -days    有效期

(2)生成服务器端证书

a. 生成服务器端私钥和CSR签名请求

 openssl req -newkey rsa:4096 -nodes -sha256 -keyout server.key -out server.csr

b. 签发服务器证书

echo subjectAltName = IP:10.72.77.176 > extfile.cnf

openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -extfile extfile.cnf -out server.crt

 x509           签发X.509格式证书命令。  

-req           表示证书输入请求。  

-days          表示有效天数  -extensions    表示按OpenSSL配置文件v3_req项添加扩展。  

-CA            表示CA证书,这里为ca.crt  

-CAkey         表示CA证书密钥,这里为ca.key  

-CAcreateserial表示创建CA证书序列号  

-extfile      指定文件

3、修改harbor.cfg

vim harbor.cfg

#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 = 10.72.77.176

#The protocol for accessing the UI and token/notification service, by default it is http.

#It can be set to https if ssl is enabled on nginx.

ui_url_protocol = https

#The path of cert and key files for nginx, they are applied only the protocol is set to https

ssl_cert = /data/cert/server.crt

ssl_cert_key = /data/cert/server.key

4、设置docker证书

# 如果如下目录不存在,请创建,如果有域名请按此格式依次创建

mkdir -p /etc/docker/certs.d/10.72.77.176

# 如果端口为443,则不需要指定。如果为自定义端口,请指定端口

# /etc/docker/certs.d/yourdomain.com:port

# 将ca根证书依次复制到上述创建的目录中

cp /data/cert/ca.crt /etc/docker/certs.d/10.72.77.176/

5、再次执行安装命令

/install.sh

6、访问网址

https://10.72.77.176

三、安装Harbor(https方式,7000端口)

在公网上,一般情况下都不暴露默认端口,避免被攻击!

以下修改harbor的默认80端口为其他端口!

这里示例修改为7000端口!

注意:以下步骤都是在harbor安装目录下操作!!!

cd /root/local/harbor

1、修改docker-compose.yml文件映射为7000端口

vim docker-compose.yml

proxy:

    image: vmware/nginx-photon:1.11.13

    container_name: nginx

    restart: always

    volumes:

      - ./common/config/nginx:/etc/nginx:z

    networks:

      - harbor

    ports:

      - 7000:80

      - 443:443

      - 4443:4443

2、执行准备命令

./prepare

3、修改common/templates/registry/config.yml文件

vim common/templates/registry/config.yml

auth:

  token:

    issuer: harbor-token-issuer

    realm: $ui_url/service/token

    rootcertbundle: /etc/registry/root.crt

service: harbor-registry

4、修改common/config/registry/config.yml文件

vim common/config/registry/config.yml

auth:

  token:

    issuer: harbor-token-issuer

    realm: https://10.72.77.176/service/token

    rootcertbundle: /etc/registry/root.crt

    service: harbor-registry

5、修改docker配置文件,设置信任的主机与端口

注意:如果https端口使用的默认443的话,这里只要配置IP地址,不需要带端口号

vim /etc/docker/daemon.json

 {

    "insecure-registries": [

        "10.72.77.176"

    ]

}

6、重新启动docker

systemctl daemon-reload

systemctl restart docker.service

7、停止harbor,重新启动并生成配置文件

docker-compose stop

./install.sh

最后,测试验证:

# docker login 10.72.77.176:7000

Username: admin

Password:

Login Succeeded

ok,完成!

四、常用命令

先进入harbor安装目录 

cd /root/local/harbor

1、常规操作

暂停harbor docker容器stop,并不删除容器

docker-compose stop

恢复harbor 恢复docker容器运行

docker-compose start

停止harbor  停止并删除docker容器

docker-compose down -v

启动harbor 启动所有docker容器

docker-compose up -d

2、修改运行配置

# 停止 harbor

docker-compose down -v

# 修改配置  

vim harbor.cfg

# 执行./prepare已更新配置到docker-compose.yml文件  

./prepare

# 启动 harbor  

docker-compose up -d

3、主要目录

日志目录 /var/log/harbor

数据目录 /data 

其中最主要是 /data/database 和 /data/registry 目录,如果你要彻底重新安装harbor,删除这两个目录即可。