1、爲何使用Harborlinux
Harbor是開源免費的軟件nginx
Harbor是面向企業級用戶的git
Harbor具備比較友好的WEB管理界面github
2、Harbor官方資源redis
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md https://github.com/goharbor/harbor/releases
3、前提條件一:安裝dockerdocker
1. 刪除舊版本的docker-cejson
# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2. 安裝依賴包vim
# yum install -y yum-utils device-mapper-persistent-data lvm2
3. 導入repo倉庫centos
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4. 安裝docker-cebash
# yum install docker-ce docker-ce-cli containerd.io -y
5. 配置阿里雲鏡像加速(可選)
# vim /etc/docker/daemon.json { "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] }
6. 啓動docker服務
# systemctl daemon-reload # systemctl start docker # systemctl enable docker
4、前提條件二:安裝docker-compose
1. 下載docker-compose可執行文件
# curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2. 賦予docker-compose可執行權限
# chmod +x /usr/local/bin/docker-compose
3. 測試,查詢docker-compose當前版本
# docker-compose --version
5、安裝配置Harbor
1. Harbor安裝包分爲在線安裝和離線安裝,本次經過在線安裝方式安裝,先經過Web頁面下載在線安裝文件而後解壓
# tar xvf harbor-online-installer-<version>.tgz
2. 修改harbor.yml配置文件
# vim harbor.yml hostname: 192.168.0.131 # 寫主機名或IP地址 http: port: 80 harbor_admin_password: Harbor12345 # UI初始化admin密碼,登陸後可修改 database: password: root123 data_volume: /data # 數據本地存放位置 log: # 日誌配置 level: info rotate_count: 50 rotate_size: 200M location: /var/log/harbor
3. 安裝harbor
# ./install.sh ### 會下載如下docker image文件,版本僅作參考 REPOSITORY TAG goharbor/redis-photon v1.8.0 goharbor/harbor-registryctl v1.8.0 goharbor/registry-photon v2.7.1-patch-2819-v1.8.0 goharbor/nginx-photon v1.8.0 goharbor/harbor-log v1.8.0 goharbor/harbor-jobservice v1.8.0 goharbor/harbor-core v1.8.0 goharbor/harbor-portal v1.8.0 goharbor/harbor-db v1.8.0 goharbor/prepare v1.8.0
4. 啓動或關閉harbor
# cd /PATH/harbor_install_dir/ # docker-compose start # docker-compose stop # docker-compose ps
5. 修改harbor配置,並從新應用和啓動
# docker-compose down -v # vim harbor.yml # ./prepare # docker-compose up -d
6. 完全刪除harbor
# cd /PATH/harbor_install_dir/ # docker-compose down -v # rm -r /data/database # rm -r /data/register
6、Docker客戶端配置
1. docker主機添加harbor倉庫地址
# vim /etc/docker/daemon.json { "insecure-registries": ["harbor_server_ip:80"] } # systemctl daemon-reload # systemctl restart docker
2. 測試,上傳本地鏡像到harbor倉庫
# docker login harbor_server_ip # docker pull hello-world # docker tag hello-world:latest harbor_server_ip:80/library/hello-world:latest # docker push harbor_server_ip:80/library/hello-world:latest
3. WEB登錄地址和默認用戶密碼
http:harbor_server_ip Username: admin Password: Harbor12345