vmware Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中, 确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等。
基于角色的访问控制
- 用户与Docker镜像仓库通过“项目”进行组织管理,一个用户可以对多个镜像仓库在同一命名空间(project)里有不同的权限。镜像复制
- 镜像可以在多个Registry实例中复制(同步)。尤其适合于负载均衡,高可用,混合云和多云的场景。图形化用户界面
- 用户可以通过浏览器来浏览,检索当前Docker镜像仓库,管理项目和命名空间。AD/LDAP
支持 - Harbor可以集成企业内部已有的AD/LDAP,用于鉴权认证管理。审计管理
- 所有针对镜像仓库的操作都可以被记录追溯,用于审计管理。国际化
- 已拥有英文、中文、德文、日文和俄文的本地化版本。更多的语言将会添加进来。RESTful API
- RESTful API 提供给管理员对于Harbor更多的操控, 使得与其它管理软件集成变得更容易。部署简单
- 提供在线和离线两种安装工具, 也可以安装到vSphere平台(OVA方式)虚拟设备。
==================================================================
Harbor依赖单机编排工具compose
[root@master wolfhttpd]# yum info docker compose
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Available Packages
Name : docker
Arch : x86_64
Epoch : 2
Version : 1.13.1
Release : 88.git07f3374.el7.centos
Size : 17 M
Repo : extras/7/x86_64
Summary : Automates deployment of containerized applications
URL : https://github.com/docker/docker
License : ASL 2.0
Description : Docker is an open-source engine that automates the deployment of any
: application as a lightweight, portable, self-sufficient container that will
: run virtually anywhere.
: Docker containers can encapsulate any payload, and will run consistently on
: and between virtually any server. The same container that a developer builds
: and tests on a laptop will run at scale, in production*, on VMs, bare-metal
: servers, OpenStack clusters, public instances, or combinations of the above.
Github上去下载,默认已经打包好了
https://github.com/goharbor/harbor
下载
wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.2.tgz
解压
tar xf harbor-offline-installer-v1.5.2.tgz -C /usr/local/
[root@master ~]# ll /usr/local/
total 4
drwxr-xr-x. 2 root root 6 Aug 12 2015 bin
drwxr-xr-x. 2 root root 6 Aug 12 2015 etc
drwxr-xr-x. 2 root root 6 Aug 12 2015 games
drwxr-xr-x 4 root root 4096 Jan 4 23:48 harbor
drwxr-xr-x. 2 root root 6 Aug 12 2015 include
drwxr-xr-x. 2 root root 6 Aug 12 2015 lib
drwxr-xr-x. 2 root root 6 Aug 12 2015 lib64
drwxr-xr-x. 2 root root 6 Aug 12 2015 libexec
drwxr-xr-x. 2 root root 6 Aug 12 2015 sbin
drwxr-xr-x. 5 root root 46 Nov 20 16:59 share
drwxr-xr-x. 2 root root 6 Aug 12 2015 src
[root@master harbor]# ll
total 1086452
drwxr-xr-x 3 root root 22 Jan 4 23:47 common
-rw-r--r-- 1 root root 1185 Jul 18 17:19 docker-compose.clair.yml
-rw-r--r-- 1 root root 1725 Jul 18 17:19 docker-compose.notary.yml
-rw-r--r-- 1 root root 3596 Jul 18 17:19 docker-compose.yml
drwxr-xr-x 3 root root 150 Jul 18 17:19 ha
-rw-r--r-- 1 root root 6956 Jul 18 17:19 harbor.cfg
-rw-r--r-- 1 root root 1111416970 Jul 18 17:22 harbor.v1.5.2.tar.gz
-rwxr-xr-x 1 root root 5773 Jul 18 17:19 install.sh
-rw-r--r-- 1 root root 10771 Jul 18 17:19 LICENSE
-rw-r--r-- 1 root root 482 Jul 18 17:19 NOTICE
-rw-r--r-- 1 root root 1030132 Jul 18 17:19 open_source_license
-rwxr-xr-x 1 root root 27840 Jul 18 17:19 prepare
[root@master harbor]# vim harbor.cfg
## Configuration file of Harbor
#This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
_version = 1.5.0
#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = master
#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http
#Maximum number of job workers in job service
max_job_workers =3
#Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off the default key/cert will be used.
#This flag also controls the creation of the notary signer's cert.
customize_crt = on
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
#The path of secretkey storage
secretkey_path = /data
#Admiral's url, comment this attribute, or set its value to NA when Harbor is standalone
admiral_url = NA
#Log files are rotated log_rotate_count times before being removed. If count is 0, old versions are removed rather than rotated.
log_rotate_count = 50
#Log files are rotated only if they grow bigger than log_rotate_size bytes. If size is followed by k, the size is assumed to be in kilobytes.
#If the M is used, the size is in megabytes, and if G is used, the size is in gigabytes. So size 100, size 100k, size 100M and size 100G
#are all valid.
log_rotate_size = 200M
#Config http proxy for Clair, e.g. http://my.proxy.com:3128
#Clair doesn't need to connect to harbor ui container via http proxy.
http_proxy =
https_proxy =
no_proxy = 127.0.0.1,localhost,ui
#NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES
#only take effect in the first boot, the subsequent changes of these properties
#should be performed on web ui
#************************BEGIN INITIAL PROPERTIES************************
#Email account settings for sending out password resetting emails.
#Email server uses the given username and password to authenticate on TLS connections to host and act as identity.
#Identity left blank to act as username.
email_identity =
email_server = smtp.mydomain.com
email_server_port = 25
email_username = sample_admin@mydomain.com
email_password = abc
email_from = admin <sample_admin@mydomain.com>
email_ssl = false
email_insecure = false
##The initial password of Harbor admin, only works for the first time when Harbor starts.
#It has no effect after the first launch of Harbor.
#Change the admin password from UI after launching Harbor.
harbor_admin_password = Harbor12345
##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
#Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
auth_mode = db_auth
#The url for an ldap endpoint.
ldap_url = ldaps://ldap.mydomain.com
#A user's DN who has the permission to search the LDAP/AD server.
#If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
#ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
#the password of the ldap_searchdn
#ldap_search_pwd = password
#The base DN from which to look up a user in LDAP/AD
ldap_basedn = ou=people,dc=mydomain,dc=com
#Search filter for LDAP/AD, make sure the syntax of the filter is correct.
#ldap_filter = (objectClass=person)
# The attribute used in a search to match a user, it could be uid, cn, email, sAMAccountName or other attributes depending on your LDAP/AD
ldap_uid = uid
#the scope to search for users, 0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE
ldap_scope = 2
#Timeout (in seconds) when connecting to an LDAP Server. The default value (and most reasonable) is 5 seconds.
ldap_timeout = 5
#Verify certificate from LDAP server
ldap_verify_cert = true
#The base dn from which to lookup a group in LDAP/AD
ldap_group_basedn = ou=group,dc=mydomain,dc=com
#filter to search LDAP/AD group
ldap_group_filter = objectclass=group
#The attribute used to name a LDAP/AD group, it could be cn, name
ldap_group_gid = cn
#The scope to search for ldap groups. 0-LDAP_SCOPE_BASE, 1-LDAP_SCOPE_ONELEVEL, 2-LDAP_SCOPE_SUBTREE
ldap_group_scope = 2
#Turn on or off the self-registration feature
self_registration = on
#The expiration time (in minute) of token created by token service, default is 30 minutes
token_expiration = 30
#The flag to control what users have permission to create projects
#The default value "everyone" allows everyone to creates a project.
#Set to "adminonly" so that only admin user can create project.
project_creation_restriction = everyone
#************************END INITIAL PROPERTIES************************
#######Harbor DB configuration section#######
#The address of the Harbor database. Only need to change when using external db.
db_host = mysql
#The password for the root user of Harbor DB. Change this before any production use.
db_password = root123
#The port of Harbor database host
db_port = 3306
#The user name of Harbor database
db_user = root
##### End of Harbor DB configuration#######
#The redis server address. Only needed in HA installation.
#address:port[,weight,password,db_index]
redis_url = redis:6379
##########Clair DB configuration############
#Clair DB host address. Only change it when using an exteral DB.
clair_db_host = postgres
#The password of the Clair's postgres database. Only effective when Harbor is deployed with Clair.
#Please update it before deployment. Subsequent update will cause Clair's API server and Harbor unable to access Clair's database.
clair_db_password = password
#Clair DB connect port
clair_db_port = 5432
#Clair DB username
clair_db_username = postgres
#Clair default database
clair_db = postgres
##########End of Clair DB configuration############
#The following attributes only need to be set when auth mode is uaa_auth
uaa_endpoint = uaa.mydomain.org
uaa_clientid = id
uaa_clientsecret = secret
uaa_verify_cert = true
uaa_ca_cert = /path/to/ca.pem
### Docker Registry setting ###
#registry_storage_provider can be: filesystem, s3, gcs, azure, etc.
registry_storage_provider_name = filesystem
#registry_storage_provider_config is a comma separated "key: value" pairs, e.g. "key1: value, key2: value2".
#Refer to https://docs.docker.com/registry/configuration/#storage for all available configuration.
registry_storage_provider_config =
#If reload_config=true, all settings which present in harbor.cfg take effect after prepare and restart harbor, it overwrites exsiting settings.
#reload_config=true
#Regular expression to match skipped environment variables
#skip_reload_env_pattern=(^EMAIL.*)|(^LDAP.*)
执行安装
[root@master harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 18.09.0
✖ Need to install docker-compose(1.7.1+) by yourself first and run this script again.
以上报错为未安装dockercompose
安装EPEL源:
yum install -y epel-release
然后安装docker-compose
yum install docker-compose
然后执行./install.sh
[root@master harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 18.09.0
Note: docker-compose version: 1.18.0
[Step 1]: loading Harbor images ...
b58bb92314e0: Loading layer [==================================================>] 136MB/136MB
7a89aaaf0cd8: Loading layer [==================================================>] 79.23MB/79.23MB
07a82504a1dc: Loading layer [==================================================>] 2.56kB/2.56kB
068e51989782: Loading layer [==================================================>] 2.56kB/2.56kB
857be3f6801e: Loading layer [==================================================>] 2.048kB/2.048kB
2005662b6f52: Loading layer [==================================================>] 22.8MB/22.8MB
dd930b5c1091: Loading layer [==================================================>] 22.8MB/22.8MB
Loaded image: vmware/registry-photon:v2.6.2-v1.5.2
Loaded image: vmware/photon:1.0
b9a9313d1f80: Loading layer [==================================================>] 457.3MB/457.3MB
a17318dff4d5: Loading layer [==================================================>] 9.216kB/9.216kB
11b0dc760d85: Loading layer [==================================================>] 9.216kB/9.216kB
ab253bfa0789: Loading layer [==================================================>] 7.68kB/7.68kB
7c41921b687e: Loading layer [==================================================>] 1.536kB/1.536kB
Loaded image: vmware/mariadb-photon:v1.5.2
710a675b6c7f: Loading layer [==================================================>] 129.1MB/129.1MB
f490081dae60: Loading layer [==================================================>] 3.584kB/3.584kB
b351b9f39140: Loading layer [==================================================>] 3.072kB/3.072kB
b60f73666570: Loading layer [==================================================>] 4.096kB/4.096kB
2c0dd8d09010: Loading layer [==================================================>] 3.584kB/3.584kB
5bd312d87e75: Loading layer [==================================================>] 9.728kB/9.728kB
Loaded image: vmware/harbor-log:v1.5.2
6c8870489188: Loading layer [==================================================>] 61.24MB/61.24MB
Loaded image: vmware/nginx-photon:v1.5.2
d6e1f5663df8: Loading layer [==================================================>] 79.23MB/79.23MB
1e7414733b92: Loading layer [==================================================>] 10.95MB/10.95MB
740974ce05ad: Loading layer [==================================================>] 17.3MB/17.3MB
8e5664ede767: Loading layer [==================================================>] 15.87kB/15.87kB
86e94116f829: Loading layer [==================================================>] 3.072kB/3.072kB
173729674517: Loading layer [==================================================>] 28.24MB/28.24MB
Loaded image: vmware/notary-signer-photon:v0.5.1-v1.5.2
22c53afb5f7e: Loading layer [==================================================>] 151MB/151MB
2b4cfcba43e3: Loading layer [==================================================>] 6.656kB/6.656kB
11d44832002d: Loading layer [==================================================>] 2.048kB/2.048kB
f805651773a5: Loading layer [==================================================>] 7.68kB/7.68kB
Loaded image: vmware/postgresql-photon:v1.5.2
b60d71996f91: Loading layer [==================================================>] 11.78kB/11.78kB
9f7d20f3523b: Loading layer [==================================================>] 2.56kB/2.56kB
1928f43498e2: Loading layer [==================================================>] 3.072kB/3.072kB
Loaded image: vmware/harbor-db:v1.5.2
74bdb194304b: Loading layer [==================================================>] 79.23MB/79.23MB
97251db4b4f7: Loading layer [==================================================>] 20.91MB/20.91MB
7c3dce375b3a: Loading layer [==================================================>] 20.91MB/20.91MB
Loaded image: vmware/harbor-jobservice:v1.5.2
3e7aac7aae19: Loading layer [==================================================>] 212.2MB/212.2MB
8e7d884dc74c: Loading layer [==================================================>] 10.93MB/10.93MB
12ed92f1f090: Loading layer [==================================================>] 2.048kB/2.048kB
81a629ba5751: Loading layer [==================================================>] 48.13kB/48.13kB
2171b5a262b0: Loading layer [==================================================>] 10.97MB/10.97MB
Loaded image: vmware/clair-photon:v2.0.4-v1.5.2
b5630b8d91ab: Loading layer [==================================================>] 79.23MB/79.23MB
89643b845018: Loading layer [==================================================>] 15.37MB/15.37MB
7b6fa7dbcef0: Loading layer [==================================================>] 15.37MB/15.37MB
Loaded image: vmware/harbor-adminserver:v1.5.2
bae5fd08868a: Loading layer [==================================================>] 79.24MB/79.24MB
ca9e737c9888: Loading layer [==================================================>] 24.41MB/24.41MB
5630a0e582d3: Loading layer [==================================================>] 7.168kB/7.168kB
68eedf2397cc: Loading layer [==================================================>] 10.56MB/10.56MB
74ac61aa9a2b: Loading layer [==================================================>] 24.4MB/24.4MB
Loaded image: vmware/harbor-ui:v1.5.2
1b5a1160526a: Loading layer [==================================================>] 136.2MB/136.2MB
24d9672d5b26: Loading layer [==================================================>] 3.072kB/3.072kB
fe4d52841f3d: Loading layer [==================================================>] 59.9kB/59.9kB
bffe30bd1941: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: vmware/redis-photon:v1.5.2
dccbbe2d4eff: Loading layer [==================================================>] 12.16MB/12.16MB
d1291eaee2a3: Loading layer [==================================================>] 17.3MB/17.3MB
610d6a304e63: Loading layer [==================================================>] 15.87kB/15.87kB
2dabac4548fb: Loading layer [==================================================>] 3.072kB/3.072kB
46189122932e: Loading layer [==================================================>] 29.46MB/29.46MB
Loaded image: vmware/notary-server-photon:v0.5.1-v1.5.2
454c81edbd3b: Loading layer [==================================================>] 135.2MB/135.2MB
e99db1275091: Loading layer [==================================================>] 395.4MB/395.4MB
051e4ee23882: Loading layer [==================================================>] 9.216kB/9.216kB
6cca4437b6f6: Loading layer [==================================================>] 9.216kB/9.216kB
1d48fc08c8bc: Loading layer [==================================================>] 7.68kB/7.68kB
0419724fd942: Loading layer [==================================================>] 1.536kB/1.536kB
543c0c1ee18d: Loading layer [==================================================>] 655.2MB/655.2MB
4190aa7e89b8: Loading layer [==================================================>] 103.9kB/103.9kB
Loaded image: vmware/harbor-migrator:v1.5.0
[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/ui/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/jobservice/config.yml
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
Creating harbor-log ... done
[Step 3]: checking existing instance of Harbor ...
Creating harbor-adminserver ... done
Creating harbor-ui ... done
Creating network "harbor_harbor" with the default driver
Creating nginx ... done
Creating harbor-db ...
Creating harbor-adminserver ...
Creating redis ...
Creating registry ...
Creating harbor-ui ...
Creating harbor-jobservice ...
Creating nginx ...
? ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://master.
For more details, please visit https://github.com/vmware/harbor .
现在可以使用
http://ip/harbor/sign-in 访问admin Harbor12345
可以添加一个用户wolf Harbor12345
普通用户登录-新建一个项目
去另一台服务器上修改daemon.json文件
[root@localhost ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://njrds9qc.mirror.aliyuncs.com"],
"insecure-registries":["10.249.100.206"]
}
重启docker服务
[root@localhost ~]# systemctl restart docker
docker tag SOURCE_IMAGE[:TAG] master/devel/IMAGE[:TAG]
登录
[root@localhost ~]# docker login 10.249.100.206
Username: wolf
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
docker push master/devel/IMAGE[:TAG]
docker push 10.249.100.206/devel/wolfhttpd:v0.1-4
docker push 10.249.100.206/devel/redis:4-alpine
[root@localhost ~]# docker tag wolfhttpd:v0.1-4 10.249.100.206/devel/wolfhttpd:v0.1-4
[root@localhost ~]# docker tag redis:4-alpine 10.249.100.206/devel/redis:4-alpine