博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
企业级docker私有仓库的配置与使用
阅读量:4677 次
发布时间:2019-06-09

本文共 8256 字,大约阅读时间需要 27 分钟。

1 搭建Harbor企业级docker仓库

搭建docker私有仓库是企业在docker使用中必不可少的步骤,harbor是由vmware几个大神开源出来的一款非常优秀的产品。因此今天来讲述一下如何在centos7环境中配置harhor。

1.1 环境准备

1.1.1 安装docker

由于docker已经放在centos7的extra源内,因此可直接使用yum进行安装配置。

1.1.1.1 安装
yum install docker
1.1.1.2 修改docker存储目录

修改配置文件/etc/sysconfig/docker

OPTIONS='--graph=/data/docker --selinux-enabled --log-driver=journald --signature-verification=false'注:--graph=/data/docker即为修改docker默认路径
1.1.1.3 配置docker镜像加速器

镜像加速器有利于快速下载镜像,修改如下:

[root@node249 tomcat8_jre8_supervisor]# cat /etc/docker/daemon.json{  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]}
1.1.1.4 启停服务&开机自启动
重新加载配置文件:systemctl daemon-reload启动:systemctl start docker.service停止:systemctl stop docker.service开机自启动:systemctl enable docker.service
1.1.2 安装docker-compose

注:操作系统不自带pip 请自行安装

pip install docker-compose
1.1.3 下载harbor
url地址:https://github.com/goharbor/harbor/releases选择所需版本。我所下载的为:harbor-online-installer-v1.6.0.tgztar -zxf /root/harbor-online-installer-v1.6.0.tgz -C /usr/local/
1.1.4 修改配置文件harbor.cfg
hostname = 192.168.2.46 harbor_admin_password = mvtech123self_registration = offproject_creation_restriction = adminonly
1.1.5 安装前检查
04.png

1.2 安装harbor

[root@harbor ~]# /usr/local/harbor/install.sh [Step 0]: checking installation environment ...Note: docker version: 1.13.1Note: docker-compose version: 1.22.0[Step 1]: preparing environment ...Clearing the configuration file: ./common/config/adminserver/envClearing the configuration file: ./common/config/ui/envClearing the configuration file: ./common/config/ui/app.confClearing the configuration file: ./common/config/ui/private_key.pemClearing the configuration file: ./common/config/db/envClearing the configuration file: ./common/config/jobservice/envClearing the configuration file: ./common/config/jobservice/config.ymlClearing the configuration file: ./common/config/registry/config.ymlClearing the configuration file: ./common/config/registry/root.crtClearing the configuration file: ./common/config/registryctl/envClearing the configuration file: ./common/config/registryctl/config.ymlClearing the configuration file: ./common/config/nginx/nginx.confClearing the configuration file: ./common/config/log/logrotate.confloaded secret from file: /data/secretkeyGenerated configuration file: ./common/config/nginx/nginx.confGenerated configuration file: ./common/config/adminserver/envGenerated configuration file: ./common/config/ui/envGenerated configuration file: ./common/config/registry/config.ymlGenerated configuration file: ./common/config/db/envGenerated configuration file: ./common/config/jobservice/envGenerated configuration file: ./common/config/jobservice/config.ymlGenerated configuration file: ./common/config/log/logrotate.confGenerated configuration file: ./common/config/registryctl/envGenerated configuration file: ./common/config/ui/app.confGenerated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crtThe configuration files are ready, please use docker-compose to start the service.[Step 2]: checking existing instance of Harbor ...[Step 3]: starting Harbor ...Creating network "harbor_harbor" with the default driverPulling log (goharbor/harbor-log:v1.6.0)...Trying to pull repository docker.io/goharbor/harbor-log ... v1.6.0: Pulling from docker.io/goharbor/harbor-log51be32cd3c9d: Pull completefd9cdcfcef45: Pull complete4167b797c339: Pull completeb22d11b0e478: Pull completed5aad3df7cee: Pull completebd43de1bbd44: Pull complete7494eff3da48: Pull completeDigest: sha256:27f9e24f28393a6052b71c93b1571f2269e1d3c489f4081996a099ac88ff56ffStatus: Downloaded newer image for docker.io/goharbor/harbor-log:v1.6.0Pulling postgresql (goharbor/harbor-db:v1.6.0)...Trying to pull repository docker.io/goharbor/harbor-db ... v1.6.0: Pulling from docker.io/goharbor/harbor-db51be32cd3c9d: Already exists16bdbb239be8: Pull complete1f2308455a1a: Pull complete886c09e06dee: Pull complete4c74f43fb3f6: Pull completea5a85370032d: Pull completec393ddbdd7fb: Pull completeae546b8414b0: Pull completeDigest: sha256:ee65d512c93860bd4872be296de80c079842a64e2a4002360e720222a87ec346Status: Downloaded newer image for docker.io/goharbor/harbor-db:v1.6.0Pulling redis (goharbor/redis-photon:v1.6.0)...Trying to pull repository docker.io/goharbor/redis-photon ... v1.6.0: Pulling from docker.io/goharbor/redis-photon51be32cd3c9d: Already existsc400e93ba418: Pull complete170ae129f67d: Pull completebffa31ec55cd: Pull complete5b72a97a5506: Pull completeDigest: sha256:4095dc26d6331b4d3c25377bc02d95501c51fbba99f31f9761d321bbc17803afStatus: Downloaded newer image for docker.io/goharbor/redis-photon:v1.6.0Pulling adminserver (goharbor/harbor-adminserver:v1.6.0)...Trying to pull repository docker.io/goharbor/harbor-adminserver ... v1.6.0: Pulling from docker.io/goharbor/harbor-adminserver51be32cd3c9d: Already existsa12ecf0fa8fc: Pull complete3757394ad64f: Pull complete26ceec7e26ff: Pull completee8d90789101d: Pull completeDigest: sha256:c3ca012c2d69099ba4e3bbedc58ffe146fd10aa5129d44cc7d735edf6167959eStatus: Downloaded newer image for docker.io/goharbor/harbor-adminserver:v1.6.0Pulling registry (goharbor/registry-photon:v2.6.2-v1.6.0)...Trying to pull repository docker.io/goharbor/registry-photon ... v2.6.2-v1.6.0: Pulling from docker.io/goharbor/registry-photon51be32cd3c9d: Already existseaf5637d77d9: Pull completec68621c7e44d: Pull complete314e16c23f49: Pull completee3f6c59a8a19: Pull completee4f08365b84c: Pull complete29c822b725fa: Pull completeDigest: sha256:070dcc29fb5b34cdcc982394ead57f598160fd61bd8daee4b2a5f39ea37bd7a0Status: Downloaded newer image for docker.io/goharbor/registry-photon:v2.6.2-v1.6.0Pulling ui (goharbor/harbor-ui:v1.6.0)...Trying to pull repository docker.io/goharbor/harbor-ui ... v1.6.0: Pulling from docker.io/goharbor/harbor-ui51be32cd3c9d: Already existsec6a6b245304: Pull completea88d6c453ccb: Pull completed5e2e9e0086a: Pull completef8d7e9d8512c: Pull completea06b1a705b19: Pull completeDigest: sha256:de332db437b8df6ce05203247cbf97ac9f4953672a8c22be8858aee47a0f435fStatus: Downloaded newer image for docker.io/goharbor/harbor-ui:v1.6.0Pulling jobservice (goharbor/harbor-jobservice:v1.6.0)...Trying to pull repository docker.io/goharbor/harbor-jobservice ... v1.6.0: Pulling from docker.io/goharbor/harbor-jobservice51be32cd3c9d: Already existsffcdeda0f50f: Pull completee69daf7ff175: Pull complete840fbfb5576e: Pull completeDigest: sha256:51d2bf14cd9d1bbf082793a0556ff949937655c67569a86424210a1455f60057Status: Downloaded newer image for docker.io/goharbor/harbor-jobservice:v1.6.0Pulling proxy (goharbor/nginx-photon:v1.6.0)...Trying to pull repository docker.io/goharbor/nginx-photon ... v1.6.0: Pulling from docker.io/goharbor/nginx-photon51be32cd3c9d: Already existsedc138fa5ed7: Pull completeDigest: sha256:3270c6fc3bdaaecd16280592e916e2cfcf7c5eb54ffc46d79b507b625e3fb4c6Status: Downloaded newer image for docker.io/goharbor/nginx-photon:v1.6.0Creating harbor-log ... doneCreating redis              ... doneCreating harbor-adminserver ... doneCreating registry           ... doneCreating harbor-db          ... doneCreating harbor-ui          ... doneCreating harbor-jobservice  ... doneCreating nginx              ... done✔ ----Harbor has been installed and started successfully.----Now you should be able to visit the admin portal at http://192.168.2.46 . For more details, please visit https://github.com/goharbor/harbor .

1.3 使用harbor

web访问:http://192.168.2.46 客户端若使用harbor仓库则需进行如下配置

#修改配置文件[root@localhost ~]# cat /etc/docker/daemon.json {  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],  "insecure-registries": ["192.168.2.46"]}#重启docker服务[root@localhost ~]# systemctl restart docker
1.3.1 push镜像至harbor中
1.3.1.1 登陆
03.png
1.3.1.2 push镜像

若为从其他地方pull的镜像需要修改tag

docker tag centos:latest 192.168.2.46/library/centos:latestdocker push 192.168.2.46/library/centos:latest
1.3.2 客户端pull镜像
1.3.2.1 客户端从服务器中拉取镜像
命令如下:docker pull 192.168.2.46/library/zabbix2.4.8:v1.0
01.png
1.3.2.2 查看此客户端的镜像
02.png

2 使用harbor私有仓库

本章用来介绍私有仓库的使用

2.1 登陆

输入用户名和密码进行登陆

01.png

2.2 项目

harbor通过项目管理不同的仓库,用户可以向不同的项目中上传该项目使用的镜像

02.png
03.png

2.2 日志

日志模块记录harbor的每一步操作,方便查看操作步骤。

04.png

2.3 用户管理

本模块来管理用户

05.png

2.4 仓库管理

此模块用可以添加一些仓库,用来复制

06.png
07.png

2.5 复制管理

复制管理可以通过定时任务或立即将本仓库的镜像复制到仓库管理中的仓库中

08.png
09.png

2.6 配置管理

本模块用来对仓库进行配置管理,例如允许字注册等

10.png

转载于:https://www.cnblogs.com/sdhzdtwhm/p/9849760.html

你可能感兴趣的文章
PHPSTORM多个项目并存
查看>>
Silverlight中Binding属性RelativeSource
查看>>
Python-Mac OS X EI Capitan下安装Scrapy
查看>>
深度解析Finally(转载非原创)
查看>>
spark使用udf给dataFrame新增列
查看>>
android 定时器的使用
查看>>
超强的ACM题目类型总结
查看>>
定制TreeView控件,实现节点样式自定义及节点级别的单选、复选(转)
查看>>
mysqldump备份还原和mysqldump导入导出语句大全详解(转)
查看>>
wp7下的一个生肖查询
查看>>
AOJ 0009 Prime Number
查看>>
公司生存之道
查看>>
Java利用反射来获取一个方法的 范型化参数 Vector<Integer>的类型
查看>>
htmlparser使用举例
查看>>
[Leetcode]3Sum
查看>>
十四、web基础,用html元素制作web页面
查看>>
简明python_Day8_软件开发流程
查看>>
vhdl verilog
查看>>
LeetCode 6 ZigZag Conversion 模拟 难度:0
查看>>
bootstrap入门-4.排版及其他固定样式
查看>>