目錄
- Harbor概述
- Harbor部署
- Harbor基本使用
- Portainer圖形化管理
Harbor概述
Habor是由VMWare公司開源的容器鏡像倉庫。事實上,Habor是在Docker Registry上進行了相應的 企業級擴展,從而獲得了更加廣泛的應用,這些新的企業級特性包括:管理用戶界面,基於角色的訪 問控制 ,AD/LDAP集成以及審計日誌等,足以滿足基本企業需求。
官方地址:https://goharbor.io/
組件 | 功能 |
---|---|
harbor-adminserver | 配置管理中心 |
harbor-db | Mysql數據庫 |
harbor-jobservice | 負責鏡像複製 |
harbor-log | 配置管理中心 |
harbor-ui | Web管理頁面和API |
nginx | 前端代理,負責前端頁面和鏡像上傳/下載轉發 |
redis | 會話 |
registry | 鏡像存儲 |
Harbor部署
-
安裝docker-compose
依次執行:curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
-
解壓harbor
tar -zxvf harbor-offline-installer-v1.5.0.tgz -C ../module/
-
進入解壓後harbor文件夾更新harbor.cfg
hostname=xxx.xxx.xx.xx harbor_admin_password = xxxxx
-
添加http可信用憑證
vim /etc/docker/daemon.json
{ "registry-mirrors": ["https://eosrutsk.mirror.aliyuncs.com"], #加速鏡像地址 "insecure-registries":["192.168.98.90"] #可信用憑證 }
-
編譯安裝
./prepare ./install.sh
出現以下信息安裝啓動成功[Step 4]: starting Harbor ... Creating harbor-log ... done Creating harbor-db ... done Creating harbor-adminserver ... done Creating registry ... done Creating redis ... done Creating harbor-ui ... done Creating nginx ... done Creating harbor-jobservice ... done ✔ ----Harbor has been installed and started successfully.---- Now you should be able to visit the admin portal at http://192.168.98.90. For more details, please visit https://github.com/vmware/harbor .
-
訪問地址:http://192.168.98.90 出現以下界面成功安裝
Harbor基本使用
1.創建一個私有項目
2.添加成員
3.項目添加成員
4.將本地docker鏡像打包推送到harbor
- 私有倉庫需要登錄docker
[root@k8s-master harbor]# docker login 192.168.98.90
Username: gcx
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
[root@k8s-master harbor]#
2)本地鏡像打標籤參考harbor項目中命令
[root@k8s-master harbor]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 2622e6cca7eb 5 days ago 132MB
#本地鏡像打上標籤
[root@k8s-master harbor]# docker tag nginx 192.168.98.90/my-gcx/nginx:v1.0
[root@k8s-master harbor]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.98.90/my-gcx/nginx v1.0 2622e6cca7eb 5 days ago 132MB
nginx latest 2622e6cca7eb 5 days ago 132MB
#推送打標籤的項目到harbor上
[root@k8s-master harbor]# docker push 192.168.98.90/my-gcx/nginx:v1.0
The push refers to repository [192.168.98.90/my-gcx/nginx]
f978b9ed3f26: Layer already exists
9040af41bb66: Layer already exists
7c7d7f446182: Layer already exists
d4cf327d8ef5: Layer already exists
13cb14c2acd3: Layer already exists
v1.0: digest: sha256:0efad4d09a419dc6d574c3c3baacb804a530acd61d5eba72cb1f14e1f5ac0c8f size: 1362
[root@k8s-master harbor]#
3)查看harbor倉庫中是否存在
至此harbor基本使用完成
Portainer圖形化管理
1.初始運行portainer:
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
2.首次啓動配置用戶
3.配置完畢後,選擇本地模式
4.命令能敲的圖形化都有具體功能,自己進來多摸索,不在一一列舉
至此,本文Harbor與Portainer使用結束!