快速搭建gitlab
可以使用批量计算里的APP服务来自动配置docker与gitlab的环境,该方法适用与多台服务器以上的环境(实例台数必须大于等于2)
以下操作皆是单台ECS实例,系统为centos8.0
根据很多大佬教程汇总,完全接受真实实验测试,请放心参考以及适用
安装docker
连接阿里云服务器(当然可以是其他云)
安装依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
添加yum仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache
安装docker-ce
dnf -y install docker-ce --nobest
docker开机自启
systemctl enable --now docker
添加当前用户到docker group
usermod -aG docker $USER
newgrp docker
Docker安装gitlab
启动docker
systemctl start gitlab
查看gitlab镜像
docker search gitlab
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gitlab/gitlab-ce GitLab Community Edition docker image based … 2797 [OK]
sameersbn/gitlab Dockerized gitlab web server 1147 [OK]
gitlab/gitlab-runner GitLab CI Multi Runner used to fetch and run… 591 [OK]
twang2218/gitlab-ce-zh 汉化的 GitLab 社区版 Docker Image 211 [OK]
gitlab/gitlab-ee GitLab Enterprise Edition docker image based… 179
jangrewe/gitlab-ci-android GitLab CI image for building Android apps 53 [OK]
edbizarro/gitlab-ci-pipeline-php Docker images for build and test PHP applica… 32
centurylink/gitlab This image uses the image from sameersbn / g… 26 [OK]
klud/gitlab-runner GitLab Runner for ARM devices 22
gitlab/gitlab-runner-helper 20
ciricihq/gitlab-sonar-scanner Gitlab Docker container to run sonar-scanner… 16 [OK]
dockerphp/gitlab-ci-pipeline Gitlab CI pipeline for PHP applications 4 [OK]
gitlab/gitlab-ce-qa GitLab QA has a test suite that allows end-t… 4
sgillespie/gitlab-runner A Dockerized GitLab Runner that automaticall… 3 [OK]
gitlab/cog GitLab Bundle for Cog 3
mastertinner/gitlab-merge-request-resource A concourse resource to check for new merge … 2 [OK]
lorands/gitlab-merge-request-resource This is a fork of swisscom/gitlab-merge-requ… 1 [OK]
stanfordlegion/gitlab-ci An image for Gitlab CI. 1 [OK]
boldcommerce/gitlab-merge-request-resource Reverted build of Swisscom's resource until … 1 [OK]
samcontesse/gitlab-merge-request-resource A concourse resource to check for new merge … 1 [OK]
edtan1/gitlab-merge-request-resource GitLab Merge Request resource for ConcourseCI 0 [OK]
onaci/gitlab-runner auto-registering gitlab runner 0
mvisonneau/gitlab-ci-pipelines-exporter Prometheus / OpenMetrics exporter for GitLab… 0 [OK]
adamkl/gitlab-merge-request-resource Customized with support for gitlab ssh on di… 0 [OK]
gitlab/gitlab-ee-qa GitLab QA has a test suite that allows end-t… 0
这里有一个中文镜像,我们就选用中文版的
docker pull twang2218/gitlab-ce-zh
如果下载时速度变得很慢无法继续时,可以使用docker镜像加速器
可以访问https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors进行查询
针对Docker客户端版本大于 1.10.0 的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://9364avw5.mirror.aliyuncs.com"]
}
EOF
最好进行检查
cat /etc/docker/daemon.json
sudo systemctl daemon-reload
sudo systemctl restart docker
运行docker容器
这里的8080代表web访问端口,可以修改成您需要发放的端口,同时为了外网访问成功,请在 控制台->安全组 中开启对应的端口规则
docker run -d -p 8080:80 --restart=always --name gitlab twang2218/gitlab-ce-zh
可以打开web进行使用了
启动 GitLab 后,第一次访问时,会要求设置 root
用户的密码,密码不得小于8位。设置好后,就可以登录使用了。
- systemctl start docker #运行Docker守护进程
- systemctl stop docker #停止Docker守护进程
- systemctl restart docker #重启Docker守护进程