docker -私有镜像仓库 - harbor安装

文章目录

docker远程仓库 --》 gitee maven远程仓库

docker局域网仓库 --》 gitlab maven局域网仓库(阿里云镜像仓库)

一般公司开发中将项目的镜像放在局域网docker镜像仓库中管理。


docker:自带的registry镜像仓库过于简单

docker:harbor搭建企业级的私有镜像仓库

1、镜像仓库简介

镜像仓库作用:存储镜像,可以通过镜像仓库实现镜像的共享

镜像仓库的使用流程:

镜像仓库分类:

1、公有镜像仓库:可以理解成云仓库、公有仓库,是由某个组织、公司维护的仓库,对互联网开放,所有人共享。如官方的仓库docker hub。

2、私有镜像仓库:不对外开放。一般情况下只在公司内网中使用,用于加快镜像拉取速度、维护公司资产。

私有镜像仓库种类:

  • Registry是Docker自带的镜像仓库,部署运行非常简洁,非常适合在测试时使用。

  • Harbor

2、Harbor简介

Harbor是VMware公司开源的企业级DockerRegistry项目,其目标是帮助用户迅速搭建一个企业级的Dockerregistry服务。它以Docker公司开

源的registry为基础,提供了管理UI,基于角色的访问控制(Role Based Access Control),AD/LDAP集成、以及审计日志(Auditlogging) 等企业用户需求的功能,同时还原生支持中文。

3、下载与安装

Harbor被部署为多个Docker容器,因此可以部署在任何支持Docker的Linux服务器上,且需要Docker和Docker Compose才能安装。

3.1、下载

下载地址:https://github.com/goharbor/harbor/releases

3.2、安装

具体步骤如下所示:

3.2.1、上传harbor-offline-installer-v2.8.2.tgz到虚拟机中解压并修改配置文件

上传到 /opt 目录下

shell 复制代码
# 解压tgz包
tar -zxvf harbor-offline-installer-v2.8.2.tgz   
# 切换到解压缩后的目录下
cd harbor
# 准备配置文件
cp harbor.yml.tmpl harbor.yml
# 修改配置文件        
vim harbor.yml                                   
  - hostname修改为自己虚拟机的ip地址
  - 注释所有的https的配置: 

3.2.2、解压tgz包

shell 复制代码
[root@localhost opt]# tar -zxvf harbor-offline-installer-v2.8.2.tgz
harbor/harbor.v2.8.2.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl

3.2.3、切换到解压缩后的目录下

shell 复制代码
[root@localhost opt]# cd harbor/
[root@localhost harbor]# ls
common.sh  harbor.v2.8.2.tar.gz  harbor.yml.tmpl  install.sh  LICENSE  prepare

3.2.4、准备配置文件

shell 复制代码
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# ls
common.sh  harbor.v2.8.2.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare

3.2.5、修改配置文件

shell 复制代码
[root@localhost harbor]# vim harbor.yml

4、启动Harbor

shell 复制代码
# 进入到 Harbor 的解压目录,执行安装脚本
sh install.sh
shell 复制代码
[root@localhost harbor]# sh install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 24.0.7

[Step 1]: checking docker-compose is installed ...

Note: Docker Compose version v2.14.2

[Step 2]: loading Harbor images ...
21e7914e06fb: Loading layer [==================================================>]  38.39MB/38.39MB
bcd4591a1a5a: Loading layer [==================================================>]  91.73MB/91.73MB
af3f46d7aeca: Loading layer [==================================================>]  3.584kB/3.584kB
5380c26af354: Loading layer [==================================================>]  3.072kB/3.072kB
6462f972b019: Loading layer [==================================================>]   2.56kB/2.56kB
8cb0c83ac487: Loading layer [==================================================>]  3.072kB/3.072kB
cfbe2a0d2719: Loading layer [==================================================>]  3.584kB/3.584kB
e5293f9ebbe6: Loading layer [==================================================>]  20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.8.2
5af62c831390: Loading layer [==================================================>]  115.4MB/115.4MB
82534d457de7: Loading layer [==================================================>]  25.09MB/25.09MB
80d2f6e2bcfc: Loading layer [==================================================>]   5.12kB/5.12kB
aefafcd9796f: Loading layer [==================================================>]  6.144kB/6.144kB
97428d289bc9: Loading layer [==================================================>]  3.072kB/3.072kB
c8c0719442e6: Loading layer [==================================================>]  2.048kB/2.048kB
ab5f5c9721f1: Loading layer [==================================================>]   2.56kB/2.56kB
66301f88beb6: Loading layer [==================================================>]   2.56kB/2.56kB
75f328befa4d: Loading layer [==================================================>]   2.56kB/2.56kB
a5b05318c510: Loading layer [==================================================>]  9.728kB/9.728kB
Loaded image: goharbor/harbor-db:v2.8.2
7a03cfe8755a: Loading layer [==================================================>]  5.948MB/5.948MB
96ad7512b4d1: Loading layer [==================================================>]  4.096kB/4.096kB
d92638592515: Loading layer [==================================================>]  3.072kB/3.072kB
48d74f8d036f: Loading layer [==================================================>]  17.57MB/17.57MB
9a03dbb78886: Loading layer [==================================================>]  18.36MB/18.36MB
Loaded image: goharbor/registry-photon:v2.8.2
c00acf6f4f58: Loading layer [==================================================>]  9.095MB/9.095MB
88edeb5b4944: Loading layer [==================================================>]  3.584kB/3.584kB
06d8a79a810a: Loading layer [==================================================>]   2.56kB/2.56kB
9cb5dd968a55: Loading layer [==================================================>]   59.3MB/59.3MB
557ccce847e1: Loading layer [==================================================>]  5.632kB/5.632kB
0a049ad6bb06: Loading layer [==================================================>]  116.7kB/116.7kB
17583ba2a843: Loading layer [==================================================>]  44.03kB/44.03kB
e1c4f1102d2f: Loading layer [==================================================>]  60.26MB/60.26MB
c8ec2ddada08: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.8.2
aa80393262d7: Loading layer [==================================================>]  9.095MB/9.095MB
215dbb1a04b0: Loading layer [==================================================>]  3.584kB/3.584kB
6f2f5e479755: Loading layer [==================================================>]   2.56kB/2.56kB
147d2759d484: Loading layer [==================================================>]  47.58MB/47.58MB
8a962350165e: Loading layer [==================================================>]  48.37MB/48.37MB
Loaded image: goharbor/harbor-jobservice:v2.8.2
c2d19899aeb5: Loading layer [==================================================>]  5.948MB/5.948MB
c8ae0d52fd08: Loading layer [==================================================>]  4.096kB/4.096kB
2b478b343b5b: Loading layer [==================================================>]  17.57MB/17.57MB
bc764beb6923: Loading layer [==================================================>]  3.072kB/3.072kB
d9a27bb64f03: Loading layer [==================================================>]  31.12MB/31.12MB
b9281342e36e: Loading layer [==================================================>]  49.48MB/49.48MB
Loaded image: goharbor/harbor-registryctl:v2.8.2
49789c5ef6cb: Loading layer [==================================================>]  5.943MB/5.943MB
3c7b6ed957d3: Loading layer [==================================================>]  9.138MB/9.138MB
e9278e51e40e: Loading layer [==================================================>]  14.47MB/14.47MB
95bf8f5d9cb4: Loading layer [==================================================>]  29.29MB/29.29MB
64b7de829423: Loading layer [==================================================>]  22.02kB/22.02kB
474f017f0f6d: Loading layer [==================================================>]  14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.8.2
03882daa14fc: Loading layer [==================================================>]   6.48MB/6.48MB
277ca4b6664c: Loading layer [==================================================>]  4.096kB/4.096kB
3195ed08e16d: Loading layer [==================================================>]  3.072kB/3.072kB
1038a66bba4c: Loading layer [==================================================>]  193.4MB/193.4MB
10922dd1f89c: Loading layer [==================================================>]  14.09MB/14.09MB
7fa58b86e316: Loading layer [==================================================>]  208.3MB/208.3MB
Loaded image: goharbor/trivy-adapter-photon:v2.8.2
d9cd76d5991c: Loading layer [==================================================>]  52.85MB/52.85MB
980f48887875: Loading layer [==================================================>]  54.88MB/54.88MB
449a0993722b: Loading layer [==================================================>]  19.41MB/19.41MB
ef82d54c4095: Loading layer [==================================================>]  65.54kB/65.54kB
37ae0fc85f56: Loading layer [==================================================>]   2.56kB/2.56kB
1f410b1e1d0d: Loading layer [==================================================>]  1.536kB/1.536kB
882a66e43a76: Loading layer [==================================================>]  12.29kB/12.29kB
7a5957cadc7f: Loading layer [==================================================>]  2.622MB/2.622MB
e8a3f071c998: Loading layer [==================================================>]  416.8kB/416.8kB
Loaded image: goharbor/prepare:v2.8.2
bc73cb8addc7: Loading layer [==================================================>]  83.81MB/83.81MB
3671a4eef508: Loading layer [==================================================>]    6.1MB/6.1MB
a4eb38fb4116: Loading layer [==================================================>]  1.233MB/1.233MB
Loaded image: goharbor/harbor-portal:v2.8.2
c16f4880a6a0: Loading layer [==================================================>]  84.66MB/84.66MB
f56fbf7243e9: Loading layer [==================================================>]  3.072kB/3.072kB
031e3908240b: Loading layer [==================================================>]   59.9kB/59.9kB
d5e6d4e3eb25: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.8.2
3b33d3218a04: Loading layer [==================================================>]  9.095MB/9.095MB
df2a1c214a73: Loading layer [==================================================>]  26.03MB/26.03MB
099a3e87a796: Loading layer [==================================================>]  4.608kB/4.608kB
8a8188a617c5: Loading layer [==================================================>]  26.82MB/26.82MB
Loaded image: goharbor/harbor-exporter:v2.8.2
06059da7cd8e: Loading layer [==================================================>]  83.81MB/83.81MB
Loaded image: goharbor/nginx-photon:v2.8.2
d0000dfd32d8: Loading layer [==================================================>]  5.943MB/5.943MB
5c8f6501414b: Loading layer [==================================================>]  9.138MB/9.138MB
4e37ce9ef2f9: Loading layer [==================================================>]  15.88MB/15.88MB
519b1ca3008d: Loading layer [==================================================>]  29.29MB/29.29MB
0497bd0e9332: Loading layer [==================================================>]  22.02kB/22.02kB
88ecfe080b68: Loading layer [==================================================>]  15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.8.2


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.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/registryctl/config.yml
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: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...


[Step 5]: starting Harbor ...
[+] Running 10/10
 ⠿ Network harbor_harbor        Created                                                                                                                                                                       0.1s
 ⠿ Container harbor-log         Started                                                                                                                                                                       0.7s
 ⠿ Container harbor-portal      Started                                                                                                                                                                       1.3s
 ⠿ Container registry           Started                                                                                                                                                                       1.5s
 ⠿ Container harbor-db          Started                                                                                                                                                                       1.8s
 ⠿ Container redis              Started                                                                                                                                                                       1.7s
 ⠿ Container registryctl        Started                                                                                                                                                                       1.4s
 ⠿ Container harbor-core        Started                                                                                                                                                                       2.1s
 ⠿ Container harbor-jobservice  Started                                                                                                                                                                       2.7s
 ⠿ Container nginx              Started                                                                                                                                                                       2.7s
✔ ----Harbor has been installed and started successfully.----

5、启动关闭命令

shell 复制代码
# 启动 Harbor
docker compose -f docker-compose.yml up -d   
# 关闭 Harbor
docker compose -f docker-compose.yml stop      

6、访问harbor

用户名/密码:admin/Harbor12345

相关推荐
A ?Charis38 分钟前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision1 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge1 小时前
Docker篇(Docker Compose)
运维·docker·容器
李启柱1 小时前
项目开发流程规范文档
运维·软件构建·个人开发·设计规范
北漂IT民工_程序员_ZG2 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
力姆泰克2 小时前
看电动缸是如何提高农机的自动化水平
大数据·运维·服务器·数据库·人工智能·自动化·1024程序员节
BPM_宏天低代码2 小时前
低代码 BPA:简化业务流程自动化的新趋势
运维·低代码·自动化
sun0077003 小时前
拷贝 cp -rdp 和 cp -a
linux·运维·服务器
wowocpp3 小时前
ubuntu 22.04 server 安装 anaconda3
linux·运维·ubuntu
tingting01194 小时前
Linux 普通用户禁用sudo su - 命令
linux·运维·服务器