Docker中安装Gitlab-CE
1.Gitlab-CE
官方介绍地址:https://docs.gitlab.com/ee/install/docker.html
docker run -d \
--hostname 192.168.172.128 \
--privileged=true \
-e GITLAB_OMNIBUS_CONFIG="external_url 'http://192.168.172.128:3000'; gitlab_rails['initial_root_password'] = 'fanqi&coreqi&7'; \
gitlab_rails['gitlab_host'] = '192.168.172.128'; gitlab_rails['gitlab_port'] = 3000; gitlab_rails['gitlab_https'] = false; \
gitlab_rails['gitlab_ssh_host'] = '192.168.172.128'; gitlab_rails['gitlab_shell_ssh_port'] = 222;" \
-p 4443:443 -p 3000:3000 -p 222:22 \
--name gitlab-ce \
--restart always \
-v /home/fanqi/docker/gitlab/config:/etc/gitlab:Z \
-v /home/fanqi/docker/gitlab/logs:/var/log/gitlab:Z \
-v /home/fanqi/docker/gitlab/data:/var/opt/gitlab:Z \
--shm-size 512m \
gitlab/gitlab-ce:latest
3000是访问端口,可随意修改,其余端口正常映射即可
2.Gitlab-runner
1.安装
官方介绍地址:https://docs.gitlab.com/runner/install/docker.html
docker run -d --name gitlab-runner --restart always \
-v /mnt/docker/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
2.注册
官方介绍地址:https://docs.gitlab.com/runner/register/index.html
docker run --rm -v /mnt/docker/gitlab-runner/config:/etc/gitlab-runner:Z gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "http://192.168.58.132:3000/" \
--registration-token "xQezPzJj8MA-ybRsRyM1" \
--description "auto build image" \
--tag-list "docker" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected" \
--docker-privileged \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-volumes /mnt/docker/gitlab-runner/.nuget:/root/.nuget \
--docker-volumes /mnt/docker/gitlab-runner/.m2:/root/.m2 \
--docker-volumes /mnt/docker/gitlab-runner/.npm:/root/.npm \
--docker-volumes /mnt/docker/gitlab-runner/app:/root/app
3.后续内容补充
使用注册令牌注册Runnber的方式在 GitLab 15.6 中已弃用。
在GitLab Runner 15.10中引入了使用身份验证令牌注册的方式
相关介绍地址:
https://docs.gitlab.com/runner/register/
因此,新版本的注册命令更改为
docker run --rm -v /mnt/docker/gitlab-runner/config:/etc/gitlab-runner:Z gitlab/gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url "http://192.168.58.132:3000/" \
--token "glrt-naHrGjoFfWzxV54UAWHG" \
--description "auto build image" \
--docker-privileged \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock \
--docker-volumes /mnt/docker/gitlab-runner/.nuget:/root/.nuget \
--docker-volumes /mnt/docker/gitlab-runner/.m2:/root/.m2 \
--docker-volumes /mnt/docker/gitlab-runner/.npm:/root/.npm \
--docker-volumes /mnt/docker/gitlab-runner/app:/root/app