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
部分安裝截圖:
出現如何結果表示安裝成功:
檢視生成的映象:
訪問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搭建完成