Harbor 企业级 Docker Registry

HarBor项目:https://github.com/vmware/harbor
下载:https://github.com/vmware/harbor/releases
安装文档:https://github.com/vmware/harbor/blob/master/docs/installation_guide.md
参考:https://mritd.me/2016/06/27/Harbor-%E4%BC%81%E4%B8%9A%E7%BA%A7-Docker-Registry-%E5%88%9D%E8%AF%95/
1、安装docker、docker-compose
2、下载HarBor并安装
这里采用离线安装
[root@master ~]# tar xf harbor-offline-installer-v1.2.2.tgz
[root@master ~]# cd harbor
修改配置文件:/root/harbor/harbor.cfg
只需要修改几处就行
hostname = 192.168.101.14
db_password = redhat
3、开始安装
# sh /root/harbor/install.sh
部分安装截图:
出现如何结果表示安装成功:
查看生成的镜像:
访问web界面:
默认账号为admin,密码在配置文件中:
##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
修改docker的/etc/docker/daemon.json:由于安装的HarBor是采用的http并没有TLS认证:
[root@master harbor]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://cbd49ltj.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.101.14"]
}
重启docker:
# systemctl restart docker
如何push:
在命令行执行:
[root@master harbor]# docker login 192.168.101.14
Username: admin
Password:                  密码也是Harbor12345(就是登录的admin账号)
Login Succeeded

现在使用另一个host主机来搭建docker环境,然后将镜像推送到HarBor上:

现在在192.168.101.15上安装docker,使用HarBor这个服务(在192.168.101.14上搭建的)
配置使用HarBor:
[root@node1 ~]# cat /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://cbd49ltj.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.101.14"]
}
[root@node1 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              d123f4e55e12        2 weeks ago         197MB
[root@node1 ~]# docker tag centos:latest 192.168.101.14/library/centos:latest     
[root@node1 ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
192.168.101.14/library/centos   latest              d123f4e55e12        2 weeks ago         197MB
centos                          latest              d123f4e55e12        2 weeks ago         197MB

使用admin账号登录HarBor:

[root@node1 ~]# docker login 192.168.101.14
Username: admin
Password: 
Login Succeeded
默认的项目library:
[root@node1 ~]# docker push 192.168.101.14/library/centos
The push refers to a repository [192.168.101.14/library/centos]
cf516324493c: Pushed 
latest: digest: sha256:224d7b12549c04bba833d4626a5c51113290e55bd754d39f72d1a437539b3c68 size: 529

然后从HarBor的web界面查看library项目下的镜像:

harbor操作镜像:
在项目中标记镜像:
docker tag SOURCE_IMAGE[:TAG] 192.168.101.14/library/IMAGE[:TAG]
推送镜像到当前项目:
docker push 192.168.101.14/library/IMAGE[:TAG]

 

创建用户:
创建项目:

[root@node1 ~]# docker push 192.168.101.14/wadeson/centos       
The push refers to a repository [192.168.101.14/wadeson/centos]
cf516324493c: Preparing 
denied: requested access to the resource is denied
使用wadeson用户推送不上去,需要将wadeson用户添加到wadeson项目组:

[root@node1 ~]# docker push 192.168.101.14/wadeson/centos
The push refers to a repository [192.168.101.14/wadeson/centos]
cf516324493c: Mounted from library/centos 
latest: digest: sha256:224d7b12549c04bba833d4626a5c51113290e55bd754d39f72d1a437539b3c68 size: 529

于是http无TLS认证的HarBor registry搭建完成

posted on 2017-11-24 19:41  wadeson  阅读(3567)  评论(0编辑  收藏  举报