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信息,修改保存

问题解答

  1. runner-token获取
    在这里插入图片描述

  2. runner修改权限
    在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值