Docker GitLab-Runner安装

GitLab-Runner

安装

  1. 拉去gitlab/gitlab-runner镜像
docker pull gitlab/gitlab-runner:latest
  1. 运行容器:
docker run -d --name runner-java \
  --restart always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /opt/docker/gitlab-runner/runner-java/config:/etc/gitlab-runner \
  gitlab/gitlab-runner:latest
  1. 进去容器
docker exec -it gitlab-runner /bin/bash
  1. 开始注册流程

获取url和token:
点击设置页面
在这里插入图片描述
概览 --> Runner --> 注册一个实例Runner
在这里插入图片描述

获取url和token
请添加图片描述

注册命令:

gitlab-runner register

root@c3faf0ff4921:/# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=50 revision=d89a789a version=16.4.1
Running in system-mode.                            
                                                   
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://home.zsl0.com:9080/         
Enter the registration token:
xxxxx
Enter a description for the runner:
[c3faf0ff4921]: 
Enter tags for the runner (comma-separated):
runner-java
Enter optional maintenance note for the runner:

WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://docs.gitlab.com/ee/ci/runners/new_creation_workflow 
Registering runner... succeeded                     runner=SdP2xtsF
Enter an executor: shell, ssh, virtualbox, docker-autoscaler, docker+machine, custom, docker, parallels, instance, docker-windows, kubernetes:
docker
Enter the default Docker image (for example, ruby:2.7):
docker 
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
 
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml" 

(其他注册方式,未使用这种)使用docker命令注册:

docker exec -it gitlab-runner gitlab-runner register --non-interactive --executor "docker" --docker-image alpine:latest --url "https://xx.xx.com"  --registration-token "RQxx7UtMssiWyzWqtUMr" --description "172.30.7.17-docker-runner" --tag-list "docker-runner,share-runner,172.30.7.17-runner" --run-untagged="true"  --locked="false"  --access-level="not_protected"
  1. 编辑runner 勾选’运行未标记的作业’保存:

注:图片中名字runner-file-service为注册时填写tags标签,可自行设置

在这里插入图片描述
勾选’运行未标记的作业’ --> 保存
在这里插入图片描述

  1. 修改confi.toml配置文件
    敏感信息使用xxx替换,剩下的根据个人需求进行选择修改
concurrent = 10
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  # 用于配置远程镜像仓库拉取的认证
  environment = ['DOCKER_AUTH_CONFIG={"auths": {"registry.cn-hangzhou.aliyuncs.com/zsl0/maven-build": {"auth": "xxxxxx"}}}']
  name = "10e4d34ff34f"
  url = "http://192.168.1.81:9080/"
  id = 2
  token = "xxxx"
  token_obtained_at = 2023-10-20T03:24:03Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "docker"
  [runners.cache]
    MaxUploadedArchiveSize = 0
  [runners.docker]
    tls_verify = false
    image = "maven:latest"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    # 用于docker in docker
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
    shm_size = 0

问题合集

GitLab 域名的配置修改

GitLab 域名的配置修改

Runner容器内注册失败,提示 ‘dial tcp: lookup home.zsl0.com on 192.168.254.2:53: no such host’

报错信息:

root@c3faf0ff4921:/# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=25 revision=d89a789a version=16.4.1
Running in system-mode.                            
                                                   
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://home.zsl0.com:9080/
Enter the registration token:
xxxxx
Enter a description for the runner:
[c3faf0ff4921]: 
Enter tags for the runner (comma-separated):
runner-file-service
Enter optional maintenance note for the runner:

WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://docs.gitlab.com/ee/ci/runners/new_creation_workflow 
ERROR: Registering runner... failed                 runner=SdP2xtsF status=couldn't execute POST against http://home.zsl0.com:9080/api/v4/runners: Post "http://home.zsl0.com:9080/api/v4/runners": dial tcp: lookup home.zsl0.com on 192.168.254.2:53: no such host
PANIC: Failed to register the runner.    

解决办法(临时解决):
因为猜测是没办法解析域名导致,正好运行Runner的宿主机也是运行GitLab的机器,直接去找宿主机就行了,所以执行

echo ‘172.17.0.1 home.zsl0.com’ >> /etc/hosts

重新注册命令:

gitlab-runner register

root@c3faf0ff4921:/# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=50 revision=d89a789a version=16.4.1
Running in system-mode.                            
                                                   
Enter the GitLab instance URL (for example, https://gitlab.com/):
http://home.zsl0.com:9080/         
Enter the registration token:
xxxxx
Enter a description for the runner:
[c3faf0ff4921]: 
Enter tags for the runner (comma-separated):
runner-file-service
Enter optional maintenance note for the runner:

WARNING: Support for registration tokens and runner parameters in the 'register' command has been deprecated in GitLab Runner 15.6 and will be replaced with support for authentication tokens. For more information, see https://docs.gitlab.com/ee/ci/runners/new_creation_workflow 
Registering runner... succeeded                     runner=SdP2xtsF
Enter an executor: shell, ssh, virtualbox, docker-autoscaler, docker+machine, custom, docker, parallels, instance, docker-windows, kubernetes:
docker
Enter the default Docker image (for example, ruby:2.7):
docker 
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
 
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml" 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值