# Harbor 简单部署(For Centos7) ###### tags: `Harbor `Centos7` `docker` ## 說明 - 以下基於鏡像 CentOS-7-x86_64 進行搭建 - 檢查系統版本 >$ uname -a ``` Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ``` --- ## 安裝 docker 和 docker-compose ### 安裝 docker >$ yum install -y docker ``` Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile epel/x86_64/metalink | 4.1 kB 00:00 * base: ftp.tc.edu.tw * epel: ftp.jaist.ac.jp * extras: ftp.tc.edu.tw * updates: ftp.tc.edu.tw ... Dependency Updated: audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 policycoreutils.x86_64 0:2.5-34.el7 Complete! ``` - 啟動 docker >$ systemctl start docker - 檢查 docker 版本 >$ docker --version ``` Docker version 1.13.1, build 0be3e21/1.13.1 ``` ### 安裝 docker-compose - 下載 docker-compose 的最新版本 > $ `sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose` ``` [sudo] password for bigred: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 633 100 633 0 0 1864 0 --:--:-- --:--:-- --:--:-- 1872 100 11.2M 100 11.2M 0 0 6758k 0 0:00:01 0:00:01 --:--:-- 9070k ``` - 為 docker-compose 添加可執行權限 > $ sudo chmod +x /usr/local/bin/docker-compose - 驗證查看 docker-compose 版本 > $ docker-compose --version ``` docker-compose version 1.22.0, build f46880fe ``` --- ## 安裝 Harbor Harbor 支持在線和離線安裝方式,這裏使用離線方式,先下載 Harbor 安裝包: >$ `wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.3.tgz` ``` --2021-03-23 15:39:01-- https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.5.3.tgz Resolving storage.googleapis.com (storage.googleapis.com)... 172.217.160.80, 216.58.200.240, 2404:6800:4008:803::2010, ... Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.160.80|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 904278926 (862M) [application/x-tar] Saving to: ‘harbor-offline-installer-v1.5.3.tgz’ 100%[======================================>] 904,278,926 35.3MB/s in 26s 2021-03-23 15:39:29 (32.6 MB/s) - ‘harbor-offline-installer-v1.5.3.tgz’ saved [904278926/904278926] ``` > --- ### 解壓離線安裝包 - 解壓離線安裝包 > $ tar -zxvf harbor-offline-installer-v1.5.3.tgz ``` harbor/common/templates/ harbor/common/templates/nginx/ harbor/common/templates/nginx/nginx.https.conf harbor/common/templates/nginx/notary.server.conf harbor/common/templates/nginx/nginx.http.conf harbor/common/templates/nginx/notary.upstream.conf ... harbor/ha/docker-compose.clair.yml harbor/ha/docker-compose.clair.tpl harbor/ha/docker-compose.yml harbor/docker-compose.notary.yml harbor/docker-compose.clair.yml ``` - 移到 /opt 目錄下 >$ sudo mv harbor /opt/ - 進入到 /opt 目錄 >$ cd /opt - 查看目錄內容 >$ ll ``` total 0 drwxrwxr-x. 4 bigred bigred 256 3月 23 15:44 harbor drwxr-xr-x. 2 root root 6 10月 31 2018 rh ``` > --- ### 配置 Harbor - 進入到 harbor 目錄 >$ cd harbor - 查看目錄內容 >$ ll ``` total 895708 drwxrwxr-x. 3 bigred bigred 23 3月 23 15:43 common -rw-r--r--. 1 bigred bigred 1185 9月 12 2018 docker-compose.clair.yml -rw-r--r--. 1 bigred bigred 1725 9月 12 2018 docker-compose.notary.yml -rw-r--r--. 1 bigred bigred 3596 9月 12 2018 docker-compose.yml drwxr-xr-x. 3 bigred bigred 156 9月 12 2018 ha -rw-r--r--. 1 bigred bigred 6956 9月 12 2018 harbor.cfg -rw-r--r--. 1 bigred bigred 915878468 9月 12 2018 harbor.v1.5.3.tar.gz -rwxr-xr-x. 1 bigred bigred 5773 9月 12 2018 install.sh -rw-r--r--. 1 bigred bigred 10764 9月 12 2018 LICENSE -rw-r--r--. 1 bigred bigred 482 9月 12 2018 NOTICE -rw-r--r--. 1 bigred bigred 1247461 9月 12 2018 open_source_license -rwxr-xr-x. 1 bigred bigred 27840 9月 12 2018 prepare ``` > --- ### 編輯配置,並執行安裝 - 編輯配置文件 >$ vim harbor.cfg - 修改以下內容 ``` #修改 harbor 的啟動 ip,這裏需要依據系統 ip 設置 hostname = 192.168.105.224 #修改 harbor 的 admin 用戶的密碼 harbor_admin_password = Vatten!23 ``` > --- ### 開始安裝 Harbor - 配置 Harbor >$ ./prepare - 安裝 Harbor >$ ./install.sh > --- ### 訪問 Harbor - 瀏覽器中,輸入 `192.168.105.224`,如下: - 登錄 Harbor 以 admin 用戶,密碼 Vatten!23 登錄系統,如下: --- ## 參考網址: - https://www.itread01.com/content/1539231749.html