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
相关推荐
cxin 2020-11-06
synshitou 2020-10-21
Topbeyond 2020-08-21
happyfreeangel 2020-07-27
白开水 2020-07-19
无风的雨 2020-07-08
贤时间 2020-07-06
wishli 2020-06-28
小信 2020-06-21
leehbhs 2020-06-20
happyfreeangel 2020-06-18
83284950 2020-06-17
冯冯领队 2020-06-16
就是那个胖子 2020-06-14
83284950 2020-06-14
LiHansiyuan 2020-06-14
fcds00 2020-06-11
就是那个胖子 2020-06-11