51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

安装Docker仓库Harbor

硬件支持 {#%E7%A1%AC%E4%BB%B6%E6%94%AF%E6%8C%81}

CPU:最低2核,推荐4核

内存:最低4G,推荐8G

磁盘:最低40G,推荐160G


软件支持 {#%E8%BD%AF%E4%BB%B6%E6%94%AF%E6%8C%81}

Docker:Version17.06.0-ce以上

Docker Compose:docker-compose(v1.18.0+) 或 docker compose v2(docker-compose-plugin)版本


安装Harbor {#%E5%AE%89%E8%A3%85harbor}

下载Harbor

wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz

解压压缩包

tar -zxvf harbor-offline-installer-v2.5.3.tgz
harbor/harbor.v2.5.3.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl

进入harbor目录,复制harbor.yml.tmpl生产一个harbor.yml。

cd harbor
cp harbor.yml.tmpl harbor.yml
vim harbor.yml

修改配置,将域名修改成本机的域名或IP地址,将HTTPS部门注释掉,默认管理密码Harbor12345

# 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: 192.168.170.111


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



# Uncomment following will enable tls communication between all harbor components
=================================================================================



internal_tls:
=============



# set enabled to true means internal tls is enabled
===================================================



enabled: true
=============



# put your cert and key files on dir
====================================



dir: /etc/harbor/tls/internal
=============================



Uncomment external_url if you want to enable external proxy
===========================================================



And when it enabled the hostname will no longer used
====================================================



external_url: https://reg.mydomain.com:8433
===========================================



The initial password of Harbor admin
====================================



It only works in first time to install harbor
=============================================



Remember Change the admin password from UI after launching Harbor.
==================================================================


`harbor_admin_password: Harbor12345`


保存配置退出后,返回上一层,将harbor整个目录移至/usr/local下。

mv harbor /usr/local/harbor/

进入harbor目录里,通过install脚本开始自动启动安装

cd /usr/local/harbor/
./install.sh
`[Step 5]: starting Harbor ...
[+] Running 9/10
⠙ Network harbor_harbor        Created                                                                                                                                                                                          4.1s
✔ Container harbor-log         Started                                                                                                                                                                                          1.1s
✔ Container redis              Started                                                                                                                                                                                          1.7s
✔ Container registryctl        Started                                                                                                                                                                                          1.3s
✔ Container harbor-portal      Started                                                                                                                                                                                          1.2s
✔ Container harbor-db          Started                                                                                                                                                                                          1.7s
✔ Container registry           Started                                                                                                                                                                                          1.6s
✔ Container harbor-core        Started                                                                                                                                                                                          2.1s
✔ Container harbor-jobservice  Started                                                                                                                                                                                          2.8s
✔ Container nginx              Started                                                                                                                                                                                          2.8s
✔ ----Harbor has been installed and started successfully.----`


浏览器访问harbor,默认密码Harbor12345

上传镜像到Harbor {#%E4%B8%8A%E4%BC%A0%E9%95%9C%E5%83%8F%E5%88%B0harbor}

和registry一样,上传方需要先修改daemon文件,我这里把registry和Harbor的地址都添加了

vim /etc/docker/daemon.json
{
  "insecure-registries":["hub.monster.com:5000","hub.monster.com:80"]
}

重新加载配置,重启Docker生效

[root@ceshi ~]# systemctl daemon-reload
[root@ceshi ~]# systemctl restart docker

打标签

[root@ceshi ~]# docker tag hub.monster.com:5000/chatgpt:1.1 hub.monster.com:80/monster/chatgpt:0.1

上传镜像,注意直接上传会提示未认证,需要先通过Docker登录到我们的Harbor。

[root@ceshi ~]# docker push hub.monster.com:80/monster/chatgpt:0.1
The push refers to repository [hub.monster.com:80/monster/chatgpt]
29117c2678df: Preparing 
82c0fd5deac1: Preparing 
b47a34ba73cb: Preparing 
07b965bc2aca: Preparing 
a2c7e2a1b1ae: Preparing 
63caa1dbfd24: Waiting 
879b1e560390: Waiting 
54e2f0467614: Waiting 
a0bbbabe7b80: Waiting 
78a822fe2a2d: Waiting 
unauthorized: unauthorized to access repository: monster/chatgpt, action: push: unauthorized to access repository: monster/chatgpt, action: push
[root@ceshi ~]# docker login -u admin hub.monster.com:80
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@ceshi ~]# docker push hub.monster.com:80/monster/chatgpt:0.1
The push refers to repository [hub.monster.com:80/monster/chatgpt]
29117c2678df: Pushed
82c0fd5deac1: Pushed
b47a34ba73cb: Pushed
07b965bc2aca: Pushed
a2c7e2a1b1ae: Pushed
63caa1dbfd24: Pushed
879b1e560390: Pushed
54e2f0467614: Pushed
a0bbbabe7b80: Pushed
78a822fe2a2d: Pushed
0.1: digest: sha256:ece1b3edb2459e71cdfefaf28a04ef6719ad64f6e170f7ab69f4bd5a96b60089 size: 2420
[root@ceshi ~]# `

赞(1)
未经允许不得转载:工具盒子 » 安装Docker仓库Harbor