您好,登錄后才能下訂單哦!
本文在介紹關于docker搭建和使用harbor私有倉庫的基礎上,重點探討了其具體步驟,步驟簡單易上手操作,文章內容步步緊湊,希望大家根據這篇文章可以有所收獲。
用戶請求通過Proxy反向代理訪問Core services,UI提供web界面,token令牌,你第一次登錄之后服務器會給你一串序列號,下次直接登錄就行,你需要下載的鏡像信息,屬性,都存放在后面的database,再通過webhook回調去registry私有倉庫調取鏡像。這一系列的操作都存放在日志中。
搭建harbor私有倉庫
harbor被部署為多個docker容器,因此可以部署在任何支持docker的linux的發行版上
我們還需要docker-compose編排工具,編排工具執行了多個docker容器的操作
[root@localhost ~]# mount.cifs //192.168.100.25/compose /abc/
Password for root@//192.168.100.25/compose:
[root@localhost ~]# cd /abc/
[root@localhost abc]# ls
consul_0.9.2_linux_amd64.zip consul-template_0.19.3_linux_amd64.zip docker-compose
[root@localhost abc]# cp docker-compose /usr/local/bin/
[root@localhost abc]# tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/
[root@localhost abc]# cd /usr/local/
[root@localhost local]# ls
bin etc games harbor include lib lib64 libexec sbin share src
[root@localhost local]# cd harbor/
[root@localhost harbor]# ls
common docker-compose.yml harbor.v1.2.2.tar.gz NOTICE
docker-compose.clair.yml harbor_1_1_0_template install.sh prepare
docker-compose.notary.yml harbor.cfg LICENSE upgrade
hostname = 192.168.136.185
#開啟私有倉庫
[root@localhost harbor]# sh /usr/local/harbor/install.sh
[root@localhost harbor]# docker-compose ps
#如果一切正常,可以打開瀏覽器訪問http://192.168.136.185 的管理頁面
默認用戶名密碼是:admin,Harbor12345
#我們本地進行上傳鏡像
[root@localhost harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1
[root@localhost harbor]# docker pull cirros
[root@localhost harbor]# docker tag cirros 127.0.0.1/chen/cirros:v1
[root@localhost harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
127.0.0.1/chen/cirros v1 bc94bceaae77 12 months ago 10.3MB
cirros latest bc94bceaae77 12 months ago 10.3MB
[root@localhost harbor]# docker push 127.0.0.1/chen/cirros:v1
The push refers to repository [127.0.0.1/chen/cirros]
abbd6d6ac643: Pushed
75b99987219d: Pushed
0cc237193a30: Pushed
v1: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f19446bd size: 943
#遠程客戶端上傳鏡像到私有倉庫
#遠程登錄會報錯
[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get https://192.168.136.185/v2/: dial tcp 192.168.136.185:443: connect: connection refused
#我們要指定私有倉庫實列
[root@localhost ~]# vim /usr/lib/systemd/system/docker.service
14 ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.136.185 --containerd=/run/contai nerd/containerd.sock
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker login -u admin -p Harbor12345 http://192.168.136.185
#遠程下載私有倉庫的鏡像
[root@localhost ~]# docker pull 192.168.136.185/chen/cirros:v1
#遠程上傳鏡像到私有倉庫
[root@localhost ~]# docker push 192.168.136.185/chen/cirros:v2
The push refers to repository [192.168.136.185/chen/cirros]
abbd6d6ac643: Layer already exists
75b99987219d: Layer already exists
0cc237193a30: Layer already exists
v2: digest: sha256:96137d51e0e46006243fa2403723eb47f67818802d1175b5cde7eaa7f
#關閉harbor私有倉庫
[root@localhost harbor]# docker-compose down -v
[root@localhost harbor]# ./prepare
#開啟私有倉庫
[root@localhost harbor]# docker-compose up -d
#我們用剛才創建的用戶來登錄私有倉庫
[root@localhost harbor]# docker login http://192.168.136.185
Username: chen
Password:
docker-compose down -v
/var/log/Harbor/目錄下
rm-rf /data/database/ /data/registry/
以上就是docker搭建和使用harbor私有倉庫的詳細內容了,看完之后是否有所收獲呢?如果想了解更多相關內容,歡迎關注億速云行業資訊!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。