• Docker GitLab-Runner安装


    GitLab-Runner

    安装

    1. 拉去gitlab/gitlab-runner镜像
    docker pull gitlab/gitlab-runner:latest
    
    • 1
    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
    • 2
    • 3
    • 4
    • 5
    1. 进去容器
    docker exec -it gitlab-runner /bin/bash
    
    • 1
    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" 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

    (其他注册方式,未使用这种)使用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
    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    问题合集

    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.    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    解决办法(临时解决):
    因为猜测是没办法解析域名导致,正好运行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" 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
  • 相关阅读:
    13_C++_面向对象_1
    太酷了,用Python+Excel制作一个视频下载器,手把手教学讲解
    iNFTnews|传统Web2品牌商如何进军元宇宙?
    CF547E Mike and Friends (AC 自动机+树状数组)
    MySQL----函数
    简单地聊一聊Spring Boot的构架
    【电控笔记5.4】pwm延迟
    Allegro172版本DFM规则之Silksscreen
    【OpenGL】杂谈一、通过鼠标拖拽实现相机绕空间中的某点进行球面旋转查看
    Scheduling in Kubernetes
  • 原文地址:https://blog.csdn.net/qq_19152901/article/details/134013023