四,Docker私有仓库部署
Docker 仓库分为公共仓库和私有仓库,在企业测试环境、生产环境推荐自建内部私有仓库, 使用私有仓库的优点如下;
1 节省网络带宽,针对于每个镜像不用去 Docker 官网仓库下载;
2 下载 Docker 镜像从本地私有仓库中下载;
3 组件公司内部私有仓库,方便各部门使用,服务器管理更加统一;
4 可以基于 GIT 或者 SVN、Jenkins 更新本地 Docker 私有仓库镜像版本。 官方提供 Docker Registry 来构建本地私有仓库,目前最新版本为 v2,最新版 的 docker 已不再支持 v1,Registry v2 使用 Go 语言编写,在性能和安全性上做了 很多优化,重新设计了镜像的存储格式
- docker Harbor仓库证书签名ssl
1
2
3
4
5openssl genrsa -out ca.private.key 2048
openssl req -new -x509 -key ca.private.key -out ca.crt -days 365 -subj /C=CN/ST=Beijing/L=Beijing/O=ca/OU=ca/CN=Duocaibao/emailAddress=limaolin@gogpaly.cn
openssl genrsa -out server.private.key 2048
openssl req -new -key server.private.key -out server.csr -days 365 -subj /C=CN/ST=Beijing/L=Beijing/O=cn/OU=cn/CN=172.20.20.20/emailAddress=172.20.20.20@gogpaly.cn
openssl x509 -req -days 365 -CA ca.crt -CAkey ca.private.key -CAcreateserial -in server.csr -out server.crt - 部署Harbor准备如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55wget -c <a href="https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64">https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64</a> #下载
mv docker-compose-linux-x86_64 docker-compose
chmod o+x docker-compose
mv docker-compose /usr/sbin/
wget -c <a href="https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz">https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz</a> #下载
tar xvf harbor-offline-installer-v2.5.0.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
cat harbor.yml|grep -Ev "^$|#"
hostname: 172.20.20.20 #添加域名或者IP地址
http:
port: 80
https: #提示如果没有证书可以关闭
port: 443
certificate: /your/server.crt #添加公钥证书
private_key: /your/server.private.key #添加私钥证书
harbor_admin_password: Harbor12345 #默认镜像仓库用户密码 【admin / Harbor12345】
database:
password: root123
max_idle_conns: 100
max_open_conns: 900
data_volume: /data #镜像仓库数据存放挂载目录
trivy:
ignore_unfixed: false
skip_update: false
offline_scan: false
insecure: false
jobservice:
max_job_workers: 10
notification:
webhook_job_max_retry: 10
chart:
absolute_url: disabled
log:
level: info
local:
rotate_count: 50
rotate_size: 200M
location: /var/log/harbor
_version: 2.5.0
proxy:
http_proxy:
https_proxy:
no_proxy:
components:
<ul>
<li>core</li>
<li>jobservice</li>
<li>trivy
upload_purging:
enabled: true
age: 168h
interval: 24h
dryrun: false
./install.sh --with-trivy #开启参数 --with-trivy镜像漏洞扫描功能
赏
支付宝赞助
微信赞助


四,Docker私有仓库部署:等您坐沙发呢!