Skip to content

Instantly share code, notes, and snippets.

@dev-sareno
Created October 5, 2023 07:14
Show Gist options
  • Save dev-sareno/cdf03c06a0bf691d912d49cbe2b1a9de to your computer and use it in GitHub Desktop.
Save dev-sareno/cdf03c06a0bf691d912d49cbe2b1a9de to your computer and use it in GitHub Desktop.
Gitlab runner in Docker
$ cat <<EOT > docker-compose.yaml
version: "3"
services:
  runner:
    image: gitlab/gitlab-runner
    restart: unless-stopped
    entrypoint:
    - /bin/sh
    - -c
    - "gitlab-runner register && gitlab-runner run --user=gitlab-runner --working-directory=/home/gitlab-runner"
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - gitlab-runner-config:/etc/gitlab-runner
    environment:
      REGISTER_NON_INTERACTIVE: "true"
      RUNNER_TAG_LIST: sampleproject,localmachine,docker
      REGISTER_RUN_UNTAGGED: "true"
      REGISTRATION_TOKEN: xxxxxxxxxxx
      RUNNER_NAME: local-machine-docker
      CI_SERVER_URL: https://gitlab.example.com/
      RUNNER_EXECUTOR: docker
      DOCKER_VOLUMES: /var/run/docker.sock:/var/run/docker.sock
      DOCKER_IMAGE: ubuntu
volumes:
  gitlab-runner-config:
EOT
$ docker compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment