Harbor 企业级 Docker Registry
HarBor项目:https://github.com/vmware/harbor
参考: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
部分安装截图:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193111312-1205959466.png)
出现如何结果表示安装成功:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193134593-1947962916.png)
查看生成的镜像:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193155875-1188259656.png)
访问web界面:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193218125-1738249573.png)
默认账号为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]
创建用户:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193831812-1519133672.png)
创建项目:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193852000-1629394065.png)
[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项目组:
![](https://images2018.cnblogs.com/blog/1168897/201711/1168897-20171124193940015-31950434.png)
[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搭建完成