05-企业级私有仓库Harbor

05-企业级私有仓库Harbor

仓库的概念也就是用于存储,docker仓库用于存储镜像

镜像构建完后,很容易可以在宿主机上运行,但是如果要在其他服务器上运行,则则需要考虑镜像的分发,存储问题

公有/私有/仓库

Docker Registry有两种形式

  • 公开,开放给所有的用户,提供所有用户的搜索,拉取,提交,更新镜像,还免费管理用户镜像存放数量
    • 此类服务受到网络限制,无法即使立即拉取镜像,简单来说就是下载什么要看网速
    • 优点是可以获取大部分公开的镜像,方便使用
  • 私有范围Registry服务,在学校,企业内网中使用
    • 局域网环境中,保证镜像的拉取速度
    • 保证核心镜像数据安全
    • 存在镜像不丰富

公开服务仓库

最常见的Registry是Docker Hub也是docker默认允许用户管理镜像的Registry服务,拥有大量高质量的官方镜像

由于网络限制的原因,公开服务器在国内访问受到限制,也就是出现了针对服务的加速器。

  • 阿里云加速
  • DaoCloud加速
  • 等等

私有服务仓库

除了私有的公开服务外,还可以本地搭建私有的Docker Registry

开源的Docker Registry镜像只提供Docker Registry api 功能,没有图形化界面

1、部署docker-harbor

步骤

复制代码
1. 安装docker-compose工具
2. 下载harbor安装包
3. 修改harbor配置
4. 自动化安装

安装docker-compose

复制代码
yum install docker-compose -y

[root@docker-200 /www.yuchaoit.cn/test_dockerfile/tomcat_web/web_base]#docker-compose version
docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.0.2k-fips  26 Jan 2017

上传harbor安装包

复制代码
[root@docker-200 /www.yuchaoit.cn]#ll
total 633852
-rw-r--r-- 1 root root  32749651 Aug 25 05:02 all-game.tgz
-rw-r--r-- 1 root root 616312579 Aug 27 20:03 harbor-offline-installer-v1.9.0-rc1.tgz
drwxr-xr-x 6 root root       114 Aug 23 00:08 jd
drwxr-xr-x 5 root root        59 Aug 27 20:03 test_dockerfile
drwxr-xr-x 3 root root        98 Aug 22 23:40 xiaoniao
drwxr-xr-x 7 root root       153 Aug 23 20:42 yunpan


解压
[root@docker-200 /www.yuchaoit.cn]#ls
all-game.tgz  harbor  harbor-offline-installer-v1.9.0-rc1.tgz  jd  test_dockerfile  xiaoniao  yunpan
[root@docker-200 /www.yuchaoit.cn]#cd harbor/
[root@docker-200 /www.yuchaoit.cn/harbor]#
[root@docker-200 /www.yuchaoit.cn/harbor]#ls
harbor.v1.9.0.tar.gz  harbor.yml  install.sh  LICENSE  prepare
[root@docker-200 /www.yuchaoit.cn/harbor]#


修改harbor.yaml配置文件
[root@docker-200 /www.yuchaoit.cn/harbor]#grep -E '10.0.0.200|yuchao' harbor.yml 
hostname: 10.0.0.200
harbor_admin_password: www.yuchaoit.cn

# 安装,一键自动化安装的过程
[root@docker-200 /www.yuchaoit.cn/harbor]#./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 20.10.17

Note: docker-compose version: 1.18.0

[Step 1]: loading Harbor images ...


# 安装结果

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://10.0.0.200. 
For more details, please visit https://github.com/goharbor/harbor .

[root@docker-200 /www.yuchaoit.cn/harbor]#

访问harbor

复制代码
检查harbor进程

登录信息自己在配置文件中改个简单的

创建项目

修改docker配置,新人自建仓库

复制代码
[root@docker-200 /www.yuchaoit.cn/harbor]#cat  /etc/docker/daemon.json 
{
  "registry-mirrors" : [
    "https://ms9glx6x.mirror.aliyuncs.com"
  ],
  "insecure-registries":["http://10.0.0.200"]
}
[root@docker-200 /www.yuchaoit.cn/harbor]#
[root@docker-200 /www.yuchaoit.cn/harbor]#
[root@docker-200 /www.yuchaoit.cn/harbor]#systemctl daemon-reload
[root@docker-200 /www.yuchaoit.cn/harbor]#
[root@docker-200 /www.yuchaoit.cn/harbor]#systemctl restart docker
[root@docker-200 /www.yuchaoit.cn/harbor]#

推送本地镜像(修改镜像tag)

复制代码
镜像要推送到仓库,名字上有要求
harbor地址/项目名/镜像名:版本

[root@docker-200 /www.yuchaoit.cn/harbor]#docker tag nginx:1.17.9 10.0.0.200/my_harbor01/nginx:1.17.9
[root@docker-200 /www.yuchaoit.cn/harbor]#docker images |grep nginx
centos7_nginx                   1.20.1                     f20ce96eb5be   22 hours ago        262MB
10.0.0.200/my_harbor01/nginx    1.17.9                     5a8dfb2ca731   2 years ago         127MB
nginx                           1.17.9                     5a8dfb2ca731   2 years ago         127MB
goharbor/nginx-photon           v1.9.0                     492e9528214c   2 years ago         43.2MB
[root@docker-200 /www.yuchaoit.cn/harbor]#


登录harbor
[root@docker-200 /www.yuchaoit.cn/harbor]#
[root@docker-200 /www.yuchaoit.cn/harbor]#docker login 10.0.0.200
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
[root@docker-200 /www.yuchaoit.cn/harbor]#


推送镜像,docker自动根据名字,知道往哪推送
[root@docker-200 /www.yuchaoit.cn/harbor]#docker push 10.0.0.200/my_harbor01/nginx:1.17.9 
The push refers to repository [10.0.0.200/my_harbor01/nginx]
351816b95c49: Pushed 
0e07021aa61a: Pushed 
b60e5c3bcef2: Pushed 
1.17.9: digest: sha256:30d9dde0c4cb5ab4989a92bc2c235b995dfa88ff86c09232f309b6ad27f1c7cd size: 948
[root@docker-200 /www.yuchaoit.cn/harbor]#

检查harbor镜像

下载harbor镜像

复制代码
其他机器即可使用该镜像地址,获取私有镜像仓库内容

docker pull 10.0.0.200/my_harbor01/nginx:1.17.9

停止harbor

复制代码
[root@docker-200 /www.yuchaoit.cn/harbor]#docker-compose stop 
Stopping nginx             ... done
Stopping harbor-jobservice ... done
Stopping harbor-core       ... done
Stopping redis             ... done
Stopping registryctl       ... done
Stopping harbor-portal     ... done
Stopping registry          ... done
Stopping harbor-db         ... done
Stopping harbor-log        ... done
[root@docker-200 /www.yuchaoit.cn/harbor]#

最后

可以自己在自己得阿里云,华为云得机器上部署一个玩玩呗。

相关推荐
Ryan ZX39 分钟前
openEuler 22.03-Docker离线安装教程
运维·docker·容器
brucelee1861 小时前
Ubuntu安装单节点MicroK8s
docker·容器·kubernetes
Dobby_054 小时前
【Docker】容器网络探索(二):实战理解 host 网络
网络·docker·云原生
Gauss松鼠会14 小时前
【openGauss】构建一个兼容Oracle模式支持创建package的openGauss的docker镜像
数据库·docker·oracle·opengauss
梁正雄15 小时前
16、Docker swarm-3
运维·docker·容器
Freshman小白16 小时前
python算法打包为docker镜像(边缘端api服务)
python·算法·docker
麦兜*17 小时前
Spring Boot 应用 Docker 监控:Prometheus + Grafana 全方位监控
spring boot·后端·spring cloud·docker·prometheus
爱吃糖的小秦同学17 小时前
Docker爆红且安装非C盘处理方案
运维·docker·容器
亿牛云爬虫专家18 小时前
用 Playwright + 容器化做分布式浏览器栈:调度、会话管理与资源回收
分布式·docker·容器·浏览器·爬虫代理·新闻网站·playwright
tnan252219 小时前
基于阿里云效实现cicd记录
阿里云·ci/cd·docker·容器·自动化