您好,登錄后才能下訂單哦!
本篇內容主要講解“Docker私有鏡像倉庫Harbor的搭建方式”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Docker私有鏡像倉庫Harbor的搭建方式”吧!
Harbor GitHub主頁 https://github.com/goharbor/harbor
下載最新版本發布包,此處為 2.1.2 版本(大概500多M),如下圖:
? github 下載會很慢,可以用使用github加速工具進行下載加速!
安裝docker,可查看 《CentOS安裝Docker》
安裝docker-compose, 可查看官網安裝教程 https://docs.docker.com/compose/install
# linux 安裝 docker-compose sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose # !如果下載慢或者無法下載【可以使用github加速工具或者方法】 # 修改 docker-compose 權限 sudo chmod +x /usr/local/bin/docker-compose # 建立系統軟連接 sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose # 驗證是否成功 docker-compose version # 輸出如下,則安裝成功 docker-compose version 1.27.4, build 40524192 docker-py version: 4.3.1 CPython version: 3.7.7 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
解壓harbor軟件包:
tar -zxvf harbor-offline-installer-v2.1.2.tgz
修改配置文件:
# cd harbor/ # ll total 533416 -rw-r--r-- 1 root root 3361 Dec 9 17:19 common.sh -rw-r--r-- 1 root root 546180341 Dec 9 17:19 harbor.v2.1.2.tar.gz -rw-r--r-- 1 root root 8136 Dec 9 17:19 harbor.yml.tmpl -rwxr-xr-x 1 root root 2523 Dec 9 17:19 install.sh -rw-r--r-- 1 root root 11347 Dec 9 17:19 LICENSE -rwxr-xr-x 1 root root 1881 Dec 9 17:19 prepare ##### 準備配置文件 ############# # cp harbor.yml.tmpl harbor.yml # ls common.sh harbor.v2.1.2.tar.gz harbor.yml harbor.yml.tmpl install.sh LICENSE prepare
然后修改 配置文件 harbor.yml,【新版本的配置文件已經由harbor.cfg改為harbor.yml】 修改4處,如下圖:
hostname:可修改為IP或域名,此處修改為本機IP;
http.port:修改為非80端口即可,此處修改為9200;
harbor_admin_password:Harbor管理員密碼,按需修改;
database.password:harbor 數據庫密碼,按需修改;
https: 注釋掉這一塊,默認開啟 http, 除非你配置https證書;
執行安裝命令
./install.sh
輸出如下信息:
[root@resources harbor]# ./install.sh [Step 0]: checking if docker is installed ... Note: docker version: 20.10.1 [Step 1]: checking docker-compose is installed ... Note: docker-compose version: 1.27.4 [Step 2]: loading Harbor images ... Loaded image: goharbor/chartmuseum-photon:v2.1.2 Loaded image: goharbor/prepare:v2.1.2 Loaded image: goharbor/harbor-log:v2.1.2 Loaded image: goharbor/harbor-registryctl:v2.1.2 Loaded image: goharbor/clair-adapter-photon:v2.1.2 Loaded image: goharbor/harbor-db:v2.1.2 Loaded image: goharbor/harbor-jobservice:v2.1.2 Loaded image: goharbor/clair-photon:v2.1.2 Loaded image: goharbor/notary-signer-photon:v2.1.2 Loaded image: goharbor/harbor-portal:v2.1.2 Loaded image: goharbor/redis-photon:v2.1.2 Loaded image: goharbor/nginx-photon:v2.1.2 Loaded image: goharbor/trivy-adapter-photon:v2.1.2 Loaded image: goharbor/harbor-core:v2.1.2 Loaded image: goharbor/registry-photon:v2.1.2 Loaded image: goharbor/notary-server-photon:v2.1.2 [Step 3]: preparing environment ... [Step 4]: preparing harbor configs ... prepare base dir is set to /opt/soft/harbor WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https Generated configuration file: /config/portal/nginx.conf Generated configuration file: /config/log/logrotate.conf Generated configuration file: /config/log/rsyslog_docker.conf Generated configuration file: /config/nginx/nginx.conf Generated configuration file: /config/core/env Generated configuration file: /config/core/app.conf Generated configuration file: /config/registry/config.yml Generated configuration file: /config/registryctl/env Generated configuration file: /config/registryctl/config.yml Generated configuration file: /config/db/env Generated configuration file: /config/jobservice/env Generated configuration file: /config/jobservice/config.yml Generated and saved secret to file: /data/secret/keys/secretkey Successfully called func: create_root_cert Generated configuration file: /compose_location/docker-compose.yml Clean up the input dir [Step 5]: starting Harbor ... Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating registry ... done Creating harbor-db ... done Creating redis ... done Creating registryctl ... done Creating harbor-portal ... done Creating harbor-core ... done Creating harbor-jobservice ... done Creating nginx ... done ? ----Harbor has been installed and started successfully.---- [root@resources harbor]#
?:安裝完后,安裝目錄下會變成這樣,如下圖:
可以看到其中多出一個docker-compose.yml文件,這也是基于harbor.yml生成的供docker-compose調用創建容器的服務編排文件。
安裝完成后,通過配置中設置的IP或域名+端口,即可訪問Harbor管理控制臺,如果端口占用,可以去安裝目錄下harbor.yml文件中,對應服務的端口映射。
測試安裝是否成功,使用安裝時在harbor.yml中設置的管理員密碼,用戶名是admin,登錄控制臺:
登錄成功,進入首頁,如下圖:
至此Harbor 搭建成功!!
到此,相信大家對“Docker私有鏡像倉庫Harbor的搭建方式”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。