码迷,mamicode.com
首页 > 其他好文 > 详细

docker容器部署gitlab

时间:2020-04-17 20:25:54      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:没有   cal   ash   端口   重启   默认   res   erro   err   

#!/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

标签:没有   cal   ash   端口   重启   默认   res   erro   err   

原文地址:https://www.cnblogs.com/alusss/p/12722016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!