1. Docker仓库介绍
仓库 是集中存放镜像的地方。每个服务器上可以有多个仓库。
仓库又分为公有仓库(DockerHub、dockerpool)和私有仓库。
DockerHub:docker官方维护的一个公共仓库https://hub.docker.com,其中包括了15000多个的镜像,大部分都可以通过dockerhub直接下载镜像。也可通过docker search和docker pull命令来下载。
DockerPool:国内专业的docker技术社区,http://www.dockerpool.com也提供官方镜像的下载。
2. Harbor介绍(私有仓库服务器)
Harbor,是一个英文单词,意思是港湾,港湾是干什么的呢,就是停放货物的,而货物呢,是装在集装箱中的,说到集装箱,就不得不提到Docker容器,因为docker容器的技术正是借鉴了集装箱的原理。所以,Harbor正是一个用于存储Docker镜像的企业级Registry服务。它是由VMware公司开发的企业级Registry项目Harbor,其的目标是帮助用户迅速搭建一个企业级的Docker registry 服务。它以Docker公司开源的registry 为基础,提供了管理UI, 基于角色的访问控制(RoleBased Access Control),AD/LDAP集成、以及审计日志(Auditlogging) 等企业用户需求的功能,同时还原生支持中文,对广大中国用户是一个好消息。
2.1 Harbor核心组件解释
- Proxy:他是一个nginx的前端代理,代理Harbor的registry,UI, token等服务。
- db:负责储存用户权限、审计日志、Dockerimage分组信息等数据。
- UI:提供图形化界面,帮助用户管理registry上的镜像, 并对用户进行授权。
- jobsevice:jobsevice是负责镜像复制工作的,他和registry通信,从一个registry pull镜像然后push到另一个registry,并记录job_log。
- Adminserver:是系统的配置管理中心附带检查存储用量,ui和jobserver启动时候回需要加载adminserver的配置。
- Registry:镜像仓库,负责存储镜像文件。
- Log:为了帮助监控Harbor运行,负责收集其他组件的log,供日后进行分析。
3. 主机搭建环境
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
4. 搭建步骤
4.1 下载harbor离线包
先下载docker安装包并且下载 harbor对应1.17.0+以上版本的docker-compose
curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
首先我们需要在github上搜索harbor下载地址。下载地址:https://github.com/goharbor/harbor/releases
笔者选择的V1.7.0版本进行安装
wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.1.tgz
tar zxvf harbor-offline-installer-v1.7.1.tgz
解压tar包后目录结构
common docker-compose.clair.yml docker-compose.yml harbor.v1.7.1.tar.gz LICENSE prepare
docker-compose.chartmuseum.yml docker-compose.notary.yml harbor.cfg install.sh open_source_license
笔者修改的harbor.cfg文件内容如下,具体hostname和passwd根据自己的具体情况更改。
hostname = harbor.com
harbor_admin_password = 12345
接下来进行harbor安装具体安装信息如下:
./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 1.13.1
Note: docker-compose version: 1.17.1
[Step 1]: loading Harbor images ...
ae18db924eef: Loading layer [==================================================>] 32.92 MB/32.92 MB
1c06074dba9c: Loading layer [==================================================>] 8.955 MB/8.955 MB
7a719a639e34: Loading layer [==================================================>] 3.072 kB/3.072 kB
49f7bca05da9: Loading layer [==================================================>] 2.56 kB/2.56 kB
e86d69bef97e: Loading layer [==================================================>] 2.56 kB/2.56 kB
81e122d773f5: Loading layer [==================================================>] 2.048 kB/2.048 kB
5fe5adb8cf31: Loading layer [==================================================>] 22.8 MB/22.8 MB
d760045419e4: Loading layer [==================================================>] 22.8 MB/22.8 MB
Loaded image: goharbor/registry-photon:v2.6.2-v1.7.1
c0f668a21621: Loading layer [==================================================>] 133.2 MB/133.2 MB
f8cb0bf39ff2: Loading layer [==================================================>] 684 MB/684 MB
444ac38a117b: Loading layer [==================================================>] 7.68 kB/7.68 kB
2e16f24ac8bc: Loading layer [==================================================>] 212 kB/212 kB
Loaded image: goharbor/harbor-migrator:v1.7.1
fa2dcaba747a: Loading layer [==================================================>] 8.955 MB/8.955 MB
eeaaf4c760eb: Loading layer [==================================================>] 15.6 MB/15.6 MB
98ffd6175b61: Loading layer [==================================================>] 18.94 kB/18.94 kB
fc1db6c4f652: Loading layer [==================================================>] 15.6 MB/15.6 MB
Loaded image: goharbor/harbor-adminserver:v1.7.1
8d55a6a034d6: Loading layer [==================================================>] 8.955 MB/8.955 MB
01ef68a17913: Loading layer [==================================================>] 27.24 MB/27.24 MB
f9258cfa4b48: Loading layer [==================================================>] 5.632 kB/5.632 kB
dcf5c61ede76: Loading layer [==================================================>] 27.24 MB/27.24 MB
Loaded image: goharbor/harbor-core:v1.7.1
1f65d10893c9: Loading layer [==================================================>] 50.39 MB/50.39 MB
358f40be2091: Loading layer [==================================================>] 3.584 kB/3.584 kB
c7f3ef058d0b: Loading layer [==================================================>] 3.072 kB/3.072 kB
154caf7c7173: Loading layer [==================================================>] 4.096 kB/4.096 kB
42c7764aa777: Loading layer [==================================================>] 3.584 kB/3.584 kB
023f3a96f324: Loading layer [==================================================>] 10.24 kB/10.24 kB
Loaded image: goharbor/harbor-log:v1.7.1
a1b528067504: Loading layer [==================================================>] 8.955 MB/8.955 MB
2d3d34f3ba5b: Loading layer [==================================================>] 21.51 MB/21.51 MB
a5da70777097: Loading layer [==================================================>] 21.51 MB/21.51 MB
Loaded image: goharbor/harbor-jobservice:v1.7.1
ab31dfc84e9d: Loading layer [==================================================>] 8.954 MB/8.954 MB
b130423af762: Loading layer [==================================================>] 13.43 MB/13.43 MB
357c059d0598: Loading layer [==================================================>] 17.3 MB/17.3 MB
fabc6edfac55: Loading layer [==================================================>] 11.26 kB/11.26 kB
cfaa3b5d445a: Loading layer [==================================================>] 3.072 kB/3.072 kB
12c73a4b2c7a: Loading layer [==================================================>] 30.72 MB/30.72 MB
Loaded image: goharbor/notary-server-photon:v0.6.1-v1.7.1
50a6467bd619: Loading layer [==================================================>] 113 MB/113 MB
6ae61fc91943: Loading layer [==================================================>] 11.46 MB/11.46 MB
5c840c272f78: Loading layer [==================================================>] 2.048 kB/2.048 kB
077d16ebcba8: Loading layer [==================================================>] 48.13 kB/48.13 kB
b822f5ff7858: Loading layer [==================================================>] 3.072 kB/3.072 kB
4548140152fd: Loading layer [==================================================>] 11.51 MB/11.51 MB
Loaded image: goharbor/clair-photon:v2.0.7-v1.7.1
232024be30e3: Loading layer [==================================================>] 3.39 MB/3.39 MB
a73624ae3fad: Loading layer [==================================================>] 4.721 MB/4.721 MB
96b8c5c532c3: Loading layer [==================================================>] 3.584 kB/3.584 kB
Loaded image: goharbor/harbor-portal:v1.7.1
e2fd12afe6e8: Loading layer [==================================================>] 63.31 MB/63.31 MB
e973513bcb58: Loading layer [==================================================>] 40.74 MB/40.74 MB
4f45af643b2b: Loading layer [==================================================>] 6.656 kB/6.656 kB
54a84094f024: Loading layer [==================================================>] 2.048 kB/2.048 kB
2d78cf8a687b: Loading layer [==================================================>] 7.68 kB/7.68 kB
e96067b83a72: Loading layer [==================================================>] 2.56 kB/2.56 kB
38a7d304147f: Loading layer [==================================================>] 2.56 kB/2.56 kB
a36c0cb6a35a: Loading layer [==================================================>] 2.56 kB/2.56 kB
Loaded image: goharbor/harbor-db:v1.7.1
b0c31ad64c85: Loading layer [==================================================>] 65.01 MB/65.01 MB
22fbab41769e: Loading layer [==================================================>] 3.072 kB/3.072 kB
7f28bf5373b2: Loading layer [==================================================>] 59.9 kB/59.9 kB
abb9969cff2a: Loading layer [==================================================>] 61.95 kB/61.95 kB
Loaded image: goharbor/redis-photon:v1.7.1
933cd9a15fc5: Loading layer [==================================================>] 3.39 MB/3.39 MB
Loaded image: goharbor/nginx-photon:v1.7.1
6ee16a137af2: Loading layer [==================================================>] 8.955 MB/8.955 MB
954443cb7d20: Loading layer [==================================================>] 22.8 MB/22.8 MB
302a998137db: Loading layer [==================================================>] 3.072 kB/3.072 kB
e342723aef9b: Loading layer [==================================================>] 7.465 MB/7.465 MB
4eeb61ed730b: Loading layer [==================================================>] 30.26 MB/30.26 MB
Loaded image: goharbor/harbor-registryctl:v1.7.1
5b40d957fafd: Loading layer [==================================================>] 12.11 MB/12.11 MB
63489681dd6c: Loading layer [==================================================>] 17.3 MB/17.3 MB
696209dcd336: Loading layer [==================================================>] 11.26 kB/11.26 kB
8dc53997aa1f: Loading layer [==================================================>] 3.072 kB/3.072 kB
cb6d560a9958: Loading layer [==================================================>] 29.41 MB/29.41 MB
Loaded image: goharbor/notary-signer-photon:v0.6.1-v1.7.1
dc1e16790c89: Loading layer [==================================================>] 8.96 MB/8.96 MB
046c7e7a0100: Loading layer [==================================================>] 35.08 MB/35.08 MB
8c8428e3d6c6: Loading layer [==================================================>] 2.048 kB/2.048 kB
ebb477ee35a2: Loading layer [==================================================>] 3.072 kB/3.072 kB
19636f39e29d: Loading layer [==================================================>] 35.08 MB/35.08 MB
Loaded image: goharbor/chartmuseum-photon:v0.7.1-v1.7.1
[Step 2]: preparing environment ...
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/core/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/core/app.conf
Generated certificate, key file: ./common/config/core/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[Step 3]: checking existing instance of Harbor ...
[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ...
Creating harbor-log ... done
Creating harbor-db ...
Creating redis ...
Creating harbor-db
Creating registry ...
Creating redis
Creating registryctl ...
Creating harbor-adminserver ...
Creating registry
Creating harbor-adminserver
Creating harbor-adminserver ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating harbor-portal ...
Creating harbor-jobservice ...
Creating harbor-portal
Creating harbor-portal ... done
Creating nginx ...
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://harbor.com.
For more details, please visit https://github.com/goharbor/harbor .
未完待续......
博客著作权归本作者所有,任何形式的转载都请联系作者获得授权并注明出处。