Gitlab runner

Moki Lv6

Install

docker-compose.yml

1
2
3
4
5
6
7
8
9
10
services:
runner:
image: gitlab/gitlab-runner:v14.7.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- gitlab-runner-config:/etc/gitlab-runner
restart: always

volumes:
gitlab-runner-config: ~

Register runner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ docker exec -it $(docker ps | grep 'gitlab/gitlab-runner' | awk '{print $1}') gitlab-runner register
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://git.mydomain.com/
Enter the registration token:
xxxxxxxxxxxxxxxx
Enter a description for the runner:
[xxxx]: xxxxxx
Enter tags for the runner (comma-separated):
docker,linux
Registering runner... succeeded runner=xxxx
Enter an executor: custom, docker+machine, docker-ssh+machine, kubernetes, virtualbox, docker, docker-ssh, parallels, shell, ssh:
docker
Enter the default Docker image (for example, ruby:2.6):
busybox
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

Fix config

1
vim /var/lib/docker/volumes/git_gitlab-runner-config/_data/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
24
25
concurrent = 1
check_interval = 0

[session_server]
session_timeout = 1800

[[runners]]
name = "xxxxxx"
url = "https://git.mydomain.com/"
token = "xxxxxxxxxxxxxxxx"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "docker:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0

Verify:

  • privileged
  • volumes

Restart runner

1
docker restart $(docker ps | grep 'gitlab/gitlab-runner' | awk '{print $1}')