contos7 一键安装docker harbor脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了contos7 一键安装docker harbor脚本相关的知识,希望对你有一定的参考价值。

脚本使用说明:

因为网络问题,请先下载harbor安装包,然后上传到/root 目录下,再运行脚本
harbor 下载地址:https://github.com/goharbor/harbor/tags 脚本支持任意版本harbor安装

脚本如下:

#!/bin/bash
check_packet()
{ 
  a=`rpm -qa $1 | wc -l`
  [ a == 0 ] && yum install -y $1
}
#the funtion of installing docker
docker_install()
{
  for i in "yum-utils docker-ce docker-ce-cli containerd.io"
  do
        if [ $i = "yum-ntils" ]
        then
                check_packet $i
                yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
        else
                check_packet $i
        fi
  done
  systemctl enable docker
  systemctl start docker
}
#the funtion of installing docker-compose
compose_install()
{
  sudo curl -L "https://github.com/docker/compose/releases/download/1.25.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  chmod +x /usr/local/bin/docker-compose
}
#判断harbor安包是否存在
ls harbor-*  /root  > /dev/null  2>&1  
if [ ! $? == 0 ]
  then
        echo "please downlocal the packet of harbor from url https://github.com/goharbor/harbor/tags and copy it to /root"
        exit
  else
        harbor_packet=`ls harbor-*`
fi
#the funtion of installing harbor
harbor_install()
{
  ip = ifconfig ens33 |grep -w inet|awk ‘{print $2}‘
  cd /root && tar  zxf   $harbor_packet
  sed -i "/^hostname =/c hostname = $ip " /root/harbor/harbor.cfg
  ./prepare
  ./install.sh
}

docker_install
compose_install
harbor_install

以上是关于contos7 一键安装docker harbor脚本的主要内容,如果未能解决你的问题,请参考以下文章

contos7 一键安装 nginx脚本

Docker在contos7下的安装:

Harbor一键部署——初学者如何快速了解它?

离线手动部署docker镜像仓库——harbor仓库

13-Docker-Harbor简介及安装

Docker私有仓库Harbor安装和配置