Docker容器

基于docker-compose使用shell搭建harbor私有仓库

本文主要是介绍基于docker-compose使用shell搭建harbor私有仓库,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

版本:harbor-offline-installer-v2.2.3

提前下载好docker-compose,脚本环境为离线安装;

 1 #!/bin/bash
 2 workdir=$(pwd `dirname $0`)
 3 
 4 if [ ! -f $workdir/docker-compose ];then
 5         echo "docker-compose file is not exists." ;exit 1
 6 fi
 7 if [ ! -x $workdir/docker-compose ];then
 8         chmod +x $workdir/docker-compose
 9 fi
10 if [ -f /usr/local/bin/docker-compose ];then
11         echo "Execution file of docker-compose is already exists"; exit 1
12 fi
13 
14 cp -r $workdir/docker-compose /usr/local/bin/docker-compose
15 
16 if [ ! -f $workdir/harbor-offline-installer-v2.2.3.tgz ];then
17         echo "harbor-offine file is not exists,please check it"; exit 1
18 fi
19 read -ep "Please input derectory of harbor server: " HB
20 if [ ! -d $HB ];then
21         mkdir $HB
22 elif [ -d $HB/harbor ];then
23         echo "The target file is already exists,Please check it";exit 1
24 fi
25 tar -xvf $workdir/harbor-offline-installer-v2.2.3.tgz -C $HB &> /dev/null
26 usage=$HB/harbor
27 cp $usage/harbor.yml.tmpl $usage/harbor.yml
28 read -ep "Please input ip of harbor server:" IP
29 sed -ri "s/^hostname(.*)/hostname: $IP/g" $usage/harbor.yml
30 read -ep "Please input port number of harbor server: " PORT
31 sed -ri "s/port: 80/port: $PORT/g" $usage/harbor.yml
32 sed -ri "s/^(https)/#\1/g" $usage/harbor.yml
33 sed -ri "s/(port: 443)/#\1/g" $usage/harbor.yml
34 HOSTNAME=`cat $usage/harbor.yml |grep ^hostname |cut -d ' ' -f 2`
35 PORT=`cat $usage/harbor.yml |grep -v "#" |grep port |tr -s ' '|cut -d ' ' -f3`
36 PASSWD=`cat $usage/harbor.yml |grep -v "#"|grep -w harbor_admin_password |cut -d' ' -f 2`
37 echo -e "\033[35m ……url for harbor server is : $HOSTNAME:$PORT……\033[0m"
38 echo -e "\033[31m ……password for harbor server is : $PASSWD……\033[31m"
39 docker load -i $usage/harbor.v2.2.3.tar.gz
40 bash $usage/prepare &> /dev/null
41 bash $usage/install &> /dev/null
42 cd $usage
43 docker-compose up -d
44 docker ps -a

 

这篇关于基于docker-compose使用shell搭建harbor私有仓库的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!