1.??? 環(huán)境準(zhǔn)備
搭建使用虛擬機(jī),所裝操作系統(tǒng)是Centos7,以下是安裝的軟件和版本需求
Docker: Version >= 1.10.0
Docker-compse: Version >= 1.6.0
Harbor: Version 1.2.2
2.搭建過程
(1)Docker安裝
yum安裝 yum install docker
(2)Docker-compose安裝
a) 拷貝docker-compose-Linux-x86_64到/usr/local/bin目錄下
b) 對(duì)二進(jìn)制文件賦可執(zhí)行權(quán)限
chmod +x /usr/local/bin/docker-compose
c) 測(cè)試下是否安裝成功
docker-compose –version
(3)Harbor搭建
a)下載Harbor離線安裝包(具體文件參照上層目錄 harbor-offline-installer-v1.2.2.tgz),將文件拷貝至虛擬機(jī),并解壓
tar xvf harbor-offline-installer-v1.2.2.tgz
b) 配置Harbor
解壓之后,目錄下會(huì)生成harbor文件夾,進(jìn)入文件夾中修改harbor.cfg文件,將hostname修改為虛擬機(jī)ip地址
c)執(zhí)行prepare腳本,創(chuàng)建docker-compose中需要的配置文件
./prepare
d)檢查docker-compose.yml文件,檢查所有容器中volumes對(duì)應(yīng)的本地目錄是否存在,如果不存在則手動(dòng)創(chuàng)建
e) 執(zhí)行安裝腳本
./install.sh
[root@localhost harbor]# ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 1.10.3
Note: docker-compose version: 1.17.1
[Step 1]: loading Harbor images ...
[Step 2]: preparing environment ...
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/ui/env
Clearing the configuration file: ./common/config/ui/app.conf
Clearing the configuration file: ./common/config/ui/private_key.pem
Clearing the configuration file: ./common/config/db/env
Clearing the configuration file: ./common/config/jobservice/env
Clearing the configuration file: ./common/config/jobservice/app.conf
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/nginx/nginx.conf
loaded secret from file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/app.conf
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[Step 3]: checking existing instance of Harbor ...
Note: stopping existing Harbor instance ...
[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ...
Creating harbor-log ... done
Creating harbor-adminserver ...
Creating registry ...
Creating harbor-adminserver
Creating harbor-db ...
Creating registry
Creating registry ... done
Creating harbor-ui ...
Creating harbor-ui ... done
Creating harbor-jobservice ...
Creating nginx ...
Creating harbor-jobservice
Creating nginx ... done
? ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal athttp://100.2.104.51.
For more details, please visithttps://github.com/vmware/harbor.
f)查看是否所有容器都已經(jīng)創(chuàng)建成功并處于UP狀態(tài)
docker ps

如果有容器不是狀態(tài)不是UP,則沒有搭建成功,需要從步驟e)重新開始
g)訪問Harbor
訪問http://100.2.104.51,頁面如下
