docker容器部署gitlab

Posted alusss

tags:

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

#!/bin/bash

serverName="gitlab"
imageName="gitlab/gitlab-ce:latest"
#imageName="gitlab/gitlab-ee:latest"

function runServer(){
    docker run --detach         -p 9443:443         -p 9080:80         -p 10022:22         --name ${serverName}         -/gitlab-data/etc:/etc/gitlab         -/gitlab-data/log:/var/log/gitlab         -/gitlab-data/data:/var/opt/gitlab         -v /etc/localtime:/etc/localtime         --restart=unless-stopped         ${imageName}
}

runningCount=`docker ps -f status=running -f status=restarting | grep -w ${serverName} |wc -l`;
if [[ ${runningCount} > 0 ]];then
    echo "docker restart 重启项目:${serverName}"
    docker restart ${serverName}
    exit 0
fi

serverCount=`docker ps -f status=exited -f status=created | grep -w ${serverName} |wc -l`;
# 判断是否已经启动过,且端口为默认端口
if [[ ${serverCount} > 0 ]];then
    if [[ ${serverCount} > 1 ]]; then
        echo "Error : 查找到多个 ${serverName} 容器,请手动启动"
        exit 1
    else
        echo "docker start 启动项目:${serverName}"
        docker start ${serverName}
    fi
else
    name=${imageName%%:*}
    tag=${imageName##*:}
    # 判断是否有该镜像
    imageCount=`docker images | grep -w ${name} | wc -l`;

    if [[ ${imageCount} > 0 ]];then
        echo "docker run 第一次启动项目: ${imageName}"
        runServer
    else
        echo "Error : 还没有该镜像"
        exit 1
    fi
fi


以上是关于docker容器部署gitlab的主要内容,如果未能解决你的问题,请参考以下文章

docker容器部署gitlab

云原生之docker实战使用docker部署gitlab平台

jenkins+docker+gitlab自动化部署

Python3 - Docker 安装部署Gitlab代码托管教程

Python3 - Docker 安装部署Gitlab代码托管教程

Python3 - Docker 安装部署Gitlab代码托管教程