本文主要是介绍ubuntu 20.04gitlab-runner docker方式安装使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
需求: 新增一个办公室的runner来跑CI,本次机器为全新机器无基础环境,详细操作步骤如下:
# 新建gitlab-runner用户
vim add_gitlab-runner_user.sh
apt-get install vim
# 安装docker
apt-get update
# 安装 apt 依赖包,用于通过HTTPS来获取仓库:
apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# 添加 Docker 的官方 GPG 密钥:
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 使用以下指令设置稳定版仓库
add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \$(lsb_release -cs) \stable"
# 安装最新版本的 Docker Engine-Community 和 containerd
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io
systemctl status docker.service
# 命令自动补全
vim /etc/bash.bashrc# 官网 https://docs.gitlab.com/runner/install/docker.html
# Use local system volume mounts to start the Runner container
docker run -d --name gitlab-runner --restart always \-v /srv/gitlab-runner/config:/etc/gitlab-runner \-v /var/run/docker.sock:/var/run/docker.sock \gitlab/gitlab-runner:latest
# To register a runner using a Docker container
docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
1. Enter your GitLab instance URL (also known as the gitlab-ci coordinator URL).
**[gitlab地址]**
2. Enter the token you obtained to register the runner.[runner-token]
3. Enter a description for the runner. You can change this value later in the GitLab user interface.
[自定义,随便写]
4. Enter the tags associated with the runner, separated by commas. You can change this value later in the GitLab user interface.
[自定义,随便写]
5. Provide the runner executor. For most use cases, enter [docker.]
6. If you entered docker as your executor, you’ll be asked for the default image to be used for projects that do not define one in .gitlab-ci.yml.
[默认runner镜像,一般为alpine:latest,可以在gitlan-ci.yaml中指定镜像]# 登录gitlab 管理配置界面https://gitlab.****.com/admin/runners,发现runner状态为share/blocked,点击对应runner-token信息,修改保存
问题解答
-
runner-token获取
-
runner修改权限
这篇关于ubuntu 20.04gitlab-runner docker方式安装使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!