千家信息网

docker搭建和使用harbor私有仓库

发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,本文在介绍关于docker搭建和使用harbor私有仓库的基础上,重点探讨了其具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。Docker私有仓库架构拓扑用户请求通过
千家信息网最后更新 2026年11月01日docker搭建和使用harbor私有仓库

本文在介绍关于docker搭建和使用harbor私有仓库的基础上,重点探讨了其具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。

Docker私有仓库架构拓扑


用户请求通过Proxy反向代理访问Core services,UI提供web界面,token令牌,你第一次登录之后服务器会给你一串序列号,下次直接登录就行,你需要下载的镜像信息,属性,都存放在后面的database,再通过webhook回调去registry私有仓库调取镜像。这一系列的操作都存放在日志中。

搭建harbor私有仓库

harbor被部署为多个docker容器,因此可以部署在任何支持docker的linux的发行版上我们还需要docker-compose编排工具,编排工具执行了多个docker容器的操作
[root@localhost ~]# mount.cifs //192.168.100.25/compose /abc/Password for root@//192.168.100.25/compose:  [root@localhost ~]# cd /abc/[root@localhost abc]# lsconsul_0.9.2_linux_amd64.zip  consul-template_0.19.3_linux_amd64.zip  docker-compose[root@localhost abc]# cp docker-compose /usr/local/bin/[root@localhost abc]# tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/[root@localhost abc]# cd /usr/local/[root@localhost local]# lsbin  etc  games  harbor  include  lib  lib64  libexec  sbin  share  src[root@localhost local]# cd harbor/[root@localhost harbor]# lscommon                     docker-compose.yml     harbor.v1.2.2.tar.gz  NOTICEdocker-compose.clair.yml   harbor_1_1_0_template  install.sh            preparedocker-compose.notary.yml  harbor.cfg             LICENSE               upgradehostname = 192.168.136.185#开启私有仓库[root@localhost harbor]# sh /usr/local/harbor/install.sh[root@localhost harbor]# docker-compose ps#如果一切正常,可以打开浏览器访问http://192.168.136.185 的管理页面默认用户名密码是:admin,Harbor12345

我们先创建一个项目,我们的一类镜像可以放在里面


#我们本地进行上传镜像[root@localhost harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1[root@localhost harbor]# docker pull cirros[root@localhost harbor]# docker tag cirros 127.0.0.1/chen/cirros:v1[root@localhost harbor]# docker imagesREPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE127.0.0.1/chen/cirros       v1                  bc94bceaae77        12 months ago       10.3MBcirros                      latest              bc94bceaae77        12 months ago       10.3MB[root@localhost harbor]# docker push 127.0.0.1/chen/cirros:v1The push refers to repository [127.0.0.1/chen/cirros]abbd6d6ac643: Pushed 75b99987219d: Pushed 0cc237193a30: Pushed v1: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f19446bd size: 943

我们通过web界面查看一下镜像有没有上传成功

#远程客户端上传镜像到私有仓库#远程登录会报错[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185WARNING! Using --password via the CLI is insecure. Use --password-stdin.Error response from daemon: Get https://192.168.136.185/v2/: dial tcp 192.168.136.185:443: connect: connection refused#我们要指定私有仓库实列[root@localhost ~]# vim /usr/lib/systemd/system/docker.service 14 ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.136.185 --containerd=/run/contai    nerd/containerd.sock[root@localhost ~]# systemctl daemon-reload[root@localhost ~]# systemctl restart docker[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185#远程下载私有仓库的镜像[root@localhost ~]# docker pull 192.168.136.185/chen/cirros:v1#远程上传镜像到私有仓库[root@localhost ~]# docker push 192.168.136.185/chen/cirros:v2The push refers to repository [192.168.136.185/chen/cirros]abbd6d6ac643: Layer already exists 75b99987219d: Layer already exists 0cc237193a30: Layer already exists v2: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f

网页验证

#关闭harbor私有仓库[root@localhost harbor]# docker-compose down -v[root@localhost harbor]# ./prepare #开启私有仓库[root@localhost harbor]# docker-compose up -d

创建用户

#我们用刚才创建的用户来登录私有仓库[root@localhost harbor]# docker login http://192.168.136.185Username: chenPassword: 

在项目中我们加入一个用户

如果要移除服务容器同时保留镜像数据库/数据库

docker-compose down -v

如需重新部署,需要移除harbor服务容器全部数据

/var/log/Harbor/目录下rm-rf /data/database/ /data/registry/

以上就是docker搭建和使用harbor私有仓库的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎关注行业资讯!


仓库 私有 镜像 用户 容器 登录 内容 数据 服务 多个 工具 数据库 步骤 界面 项目 紧凑 成功 令牌 同时 基础 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网和科技技术 互联网科技保险 互联网金融与金融科技 互联网未来科技 远拓互联网科技 互联网养老 桔豆科技 互联网科技大会案例 新华互联网科技2019 互联网科技博主是什么意思 移动互联网科技股 互联网对科技的发展 互联网科技研发水平 朱啸虎曾投资哪些互联网科技企业 华中科技大学互联网的牛人 山东子淼互联网科技有限公司 广东工业互联网大赛深圳学泰科技 广州富喜互联网络科技 江苏互联网智能科技软件 中国互联网公司的科技投入 恒生科技互联网指数十大成分股 互联网核心科技是什么 广州紫鲸互联网科技 成都玖崟互联网科技有限公司乐商圈怎么样 青岛中康互联网医疗科技有限公司 互联网科技博主是什么意思 济南有互联网科技公司吗 2021互联网科技公司排名 产业互联网科技服务公司 平安好医生打造互联网科技医疗 科技发展第三阶段互联网时代
0