harbor是一个开源镜像仓库,是存储管理私有化docker镜像的工具,这里记录下部署过程以及使用方法
# 部署harbor
# 1.下载安装包
代码语言:javascript复制[root@summer6 soft]# wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.0.tgz
--2021-02-18 10:43:54-- https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.0.tgz
正在解析主机 storage.googleapis.com (storage.googleapis.com)... 172.217.160.80, 216.58.200.48, 172.217.24.16, ...
正在连接 storage.googleapis.com (storage.googleapis.com)|172.217.160.80|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:552897681 (527M) [application/x-tar]
正在保存至: “harbor-offline-installer-v1.8.0.tgz”
100%[============================================================================================================================================>] 552,897,681 7.22MB/s 用时 77s
2021-02-18 10:45:12 (6.84 MB/s) - 已保存 “harbor-offline-installer-v1.8.0.tgz” [552897681/552897681])
[root@summer6 soft]# ll
-rw-r--r--. 1 root root 552897681 5月 21 2019 harbor-offline-installer-v1.8.0.tgz
# 2.解压配置
代码语言:javascript复制[root@summer6 soft]# tar -zxvf harbor-offline-installer-v1.8.0.tgz
harbor/harbor.v1.8.0.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/harbor.yml
[root@summer6 soft]# cd harbor/
[root@summer6 harbor]# ll
总用量 543152
-rw-r--r--. 1 root root 556153903 5月 16 2019 harbor.v1.8.0.tar.gz
-rw-r--r--. 1 root root 4839 5月 16 2019 harbor.yml
-rwxr-xr-x. 1 root root 5088 5月 16 2019 install.sh
-rw-r--r--. 1 root root 11347 5月 16 2019 LICENSE
-rwxr-xr-x. 1 root root 1654 5月 16 2019 prepare
[root@summer6 harbor]# vim harbor.yml //主要就是ip端口 顺便可以自己配置admin密码
hostname: 192.168.0.52
http:
port: 8084
# 3.执行安装脚本
- 这里主要加载一些镜像
[root@summer6 harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 20.10.3
Note: docker-compose version: 1.27.4
[Step 1]: loading Harbor images ...
23d9f72a5270: Loading layer [==================================================>] 33.25MB/33.25MB
1d4a1da12c02: Loading layer [==================================================>] 50.51MB/50.51MB
8eb1a006f3b0: Loading layer [==================================================>] 3.584kB/3.584kB
41b6f75847f4: Loading layer [==================================================>] 3.072kB/3.072kB
ec9bd6e4d4e8: Loading layer [==================================================>] 2.56kB/2.56kB
6d852bb664c2: Loading layer [==================================================>] 3.072kB/3.072kB
0e4ed2b5a5b8: Loading layer [==================================================>] 3.584kB/3.584kB
8dfb2b644f30: Loading layer [==================================================>] 12.29kB/12.29kB
Loaded image: goharbor/harbor-log:v1.8.0
d8c53538042b: Loading layer [==================================================>] 63.34MB/63.34MB
1b5fb7ee22e0: Loading layer [==================================================>] 47.96MB/47.96MB
a8bdca5e9d71: Loading layer [==================================================>] 6.656kB/6.656kB
f7cec940b52c: Loading layer [==================================================>] 2.048kB/2.048kB
301a4a2af7db: Loading layer [==================================================>] 7.68kB/7.68kB
e588e1e3a775: Loading layer [==================================================>] 2.56kB/2.56kB
539f28a5d0ea: Loading layer [==================================================>] 2.56kB/2.56kB
8b4a72241226: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-db:v1.8.0
c88db349fb2f: Loading layer [==================================================>] 8.972MB/8.972MB
1f2d4d72bba2: Loading layer [==================================================>] 35.77MB/35.77MB
dddbcf598df5: Loading layer [==================================================>] 2.048kB/2.048kB
0ced476c2d9c: Loading layer [==================================================>] 3.072kB/3.072kB
af24eb0bf40b: Loading layer [==================================================>] 35.77MB/35.77MB
Loaded image: goharbor/chartmuseum-photon:v0.8.1-v1.8.0
b185d348bd7d: Loading layer [==================================================>] 2.56kB/2.56kB
f032ded7f92e: Loading layer [==================================================>] 1.536kB/1.536kB
c6c822edbc47: Loading layer [==================================================>] 66.9MB/66.9MB
73ef3c4363bf: Loading layer [==================================================>] 39.75MB/39.75MB
0c490e002448: Loading layer [==================================================>] 144.4kB/144.4kB
31afe2abafb4: Loading layer [==================================================>] 3.004MB/3.004MB
Loaded image: goharbor/prepare:v1.8.0
257ebcc1c9c4: Loading layer [==================================================>] 8.967MB/8.967MB
7579d3c94fca: Loading layer [==================================================>] 38.68MB/38.68MB
323611f7dd17: Loading layer [==================================================>] 38.68MB/38.68MB
Loaded image: goharbor/harbor-jobservice:v1.8.0
587a5757a7f6: Loading layer [==================================================>] 3.548MB/3.548MB
Loaded image: goharbor/nginx-photon:v1.8.0
a61ab2060e6e: Loading layer [==================================================>] 8.967MB/8.967MB
25359ae00f57: Loading layer [==================================================>] 5.143MB/5.143MB
610a1668f8bf: Loading layer [==================================================>] 15.13MB/15.13MB
db2252abd9e0: Loading layer [==================================================>] 26.47MB/26.47MB
4f406312560b: Loading layer [==================================================>] 22.02kB/22.02kB
1cee0947e5a7: Loading layer [==================================================>] 3.072kB/3.072kB
48db2b9b0752: Loading layer [==================================================>] 46.74MB/46.74MB
Loaded image: goharbor/notary-server-photon:v0.6.1-v1.8.0
aaf447150765: Loading layer [==================================================>] 113MB/113MB
6835441e1a1d: Loading layer [==================================================>] 10.94MB/10.94MB
9f4739e3a532: Loading layer [==================================================>] 2.048kB/2.048kB
928f489135f0: Loading layer [==================================================>] 48.13kB/48.13kB
1495a1a09ada: Loading layer [==================================================>] 3.072kB/3.072kB
1a5f5b141717: Loading layer [==================================================>] 10.99MB/10.99MB
Loaded image: goharbor/clair-photon:v2.0.8-v1.8.0
66006ea937c6: Loading layer [==================================================>] 337.8MB/337.8MB
d272ba122880: Loading layer [==================================================>] 106.5kB/106.5kB
Loaded image: goharbor/harbor-migrator:v1.8.0
05bc5efb1724: Loading layer [==================================================>] 8.967MB/8.967MB
af3a6f89469a: Loading layer [==================================================>] 46.85MB/46.85MB
452d238b3e48: Loading layer [==================================================>] 5.632kB/5.632kB
36e1cb2d6ffa: Loading layer [==================================================>] 27.14kB/27.14kB
5385ffb8451e: Loading layer [==================================================>] 46.85MB/46.85MB
Loaded image: goharbor/harbor-core:v1.8.0
268091c30a67: Loading layer [==================================================>] 71.66MB/71.66MB
4433bcd802e7: Loading layer [==================================================>] 3.072kB/3.072kB
420b26399278: Loading layer [==================================================>] 59.9kB/59.9kB
8864c4b9ac3d: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.8.0
63645c97bf5d: Loading layer [==================================================>] 8.968MB/8.968MB
ccb295818ad9: Loading layer [==================================================>] 3.072kB/3.072kB
1ec2d1eefa8f: Loading layer [==================================================>] 2.56kB/2.56kB
b88acf0f9f5f: Loading layer [==================================================>] 20.1MB/20.1MB
0e7375de12e6: Loading layer [==================================================>] 20.1MB/20.1MB
Loaded image: goharbor/registry-photon:v2.7.1-patch-2819-v1.8.0
444b0c8bfeee: Loading layer [==================================================>] 3.548MB/3.548MB
ed0415346760: Loading layer [==================================================>] 6.568MB/6.568MB
572bd51089e0: Loading layer [==================================================>] 160.8kB/160.8kB
1410c2919a92: Loading layer [==================================================>] 215kB/215kB
8ecdca210598: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.8.0
7fb66591fb58: Loading layer [==================================================>] 8.968MB/8.968MB
42ec4a6394bf: Loading layer [==================================================>] 3.072kB/3.072kB
be6c2180cb57: Loading layer [==================================================>] 20.1MB/20.1MB
d956d9e974c5: Loading layer [==================================================>] 3.072kB/3.072kB
e2e0b4f17ad8: Loading layer [==================================================>] 7.465MB/7.465MB
7e29d670afe9: Loading layer [==================================================>] 27.56MB/27.56MB
Loaded image: goharbor/harbor-registryctl:v1.8.0
453732ea69d4: Loading layer [==================================================>] 13.72MB/13.72MB
c985f3824f33: Loading layer [==================================================>] 26.47MB/26.47MB
76eaa2763221: Loading layer [==================================================>] 22.02kB/22.02kB
0ef55a752948: Loading layer [==================================================>] 3.072kB/3.072kB
c5749b90723d: Loading layer [==================================================>] 45.33MB/45.33MB
Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.8.0
[Step 2]: preparing environment ...
prepare base dir is set to /home/summer/soft/harbor
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
[Step 3]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis ... done
Creating registry ... done
Creating harbor-db ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating harbor-portal ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://192.168.0.52.
For more details, please visit https://github.com/goharbor/harbor .
# 4.验证
- 此时访问ip:端口 输入密码出现如下界面即可
# harbor使用
# 1.客户端配置
代码语言:javascript复制[root@summer1]# vim /etc/docker/daemon.json
[root@summer1]# cat /etc/docker/daemon.json
{
"data-root": "/opt/docker",
"log-driver": "json-file",
"log-opts": {
"max-file": "3",
"max-size": "10m"
},
"registry-mirrors": [
"https://bmtrgdvx.mirror.aliyuncs.com",
"http://f1361db2.m.daocloud.io",
"https://hub-mirror.c.163.com",
"https://dockerhub.azk8s.cn"
],
"insecure-registries":[
"192.168.0.52:8084"
]
}
[root@summer1]# systemctl daemon-reload
[root@summer1]# systemctl restart docker.service
[root@summer1]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@summer1 opt]# docker login 192.168.0.52:8084
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
# 2.客户端上传镜像
代码语言:javascript复制[root@summer1]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres 9.6 2a89dff7e432 5 weeks ago 200MB
openjdk 8-jdk-slim 54aa8f8a7ed9 5 weeks ago 288MB
k8szuul v1 b2637b333a58 6 weeks ago 382MB
java openjdk-8-jdk d23bdf5b1b1b 4 years ago 643MB
[root@summer1]# docker tag k8szuul:v1 192.168.0.52:8084/test/k8szuul:v1
[root@summer1]# docker push 192.168.0.52:8084/test/k8szuul:v1
The push refers to repository [192.168.0.52:8084/test/k8szuul]
6867887fdfa8: Pushed
bbd58b62d190: Pushed
6fa5a6ed4d04: Pushed
f6253634dc78: Pushed
9069f84dbbe9: Pushed
bacd3af13903: Pushed
v1: digest: sha256:42d426c00b5f24868bf242f3c34d606ef829faae427d5647d25622b451eadc22 size: 1580
[root@summer1]#