2024年5月20日
Share

使用docker方式安装runner

by

方法来自某同性交友网站git

version: '3.6'
  services:
    dind:
    image: docker:20-dind
    restart: always
    privileged: true
    environment:
      DOCKER_TLS_CERTDIR: ""
    command:
      - --storage-driver=overlay2

  runner:
    restart: always
    image: registry.gitlab.com/gitlab-org/gitlab-runner:alpine
    depends_on:
      - dind
    environment:
      - DOCKER_HOST=tcp://dind:2375
    volumes:
      - $GITLAB_HOME/runner-config:/etc/gitlab-runner:z

  register-runner:
    restart: 'no'
    image: registry.gitlab.com/gitlab-org/gitlab-runner:alpine
    depends_on:
      - dind
    environment:
      - CI_SERVER_URL=${CI_SERVER_URL}
      - REGISTRATION_TOKEN=${REGISTRATION_TOKEN}
    command:
      - register
      - --non-interactive
      - --locked=false
      - --name=${RUNNER_NAME}
      - --executor=docker
      - --docker-image=docker:20-dind
      - --docker-volumes=/var/run/docker.sock:/var/run/docker.sock
    volumes:
      - $GITLAB_HOME/runner-config:/etc/gitlab-runner:z
YAML

  • $GITLAB_HOME 环境变量记得配置或者直接选择写成路径地址
  • ${CI_SERVER_URL} 配置为gitlab地址
  • ${RUNNER_NAME}配置为runner名称
  • ${REGISTRATION_TOKEN}配置为gitlab获取的token

You may also like