- Create a Docker volume to store runner config:
docker volume create gitlab-runner-vol
- Register runner with
docker
executor:
docker run --rm -it -v gitlab-runner-vol:/etc/gitlab-runner gitlab/gitlab-runner:latest register
- default image for docker executor:
maven:3.8.1-jdk-11
- Register runner with
shell
executor:
docker run --rm -it -v gitlab-runner-vol:/etc/gitlab-runner gitlab/gitlab-runner:latest register
- Tweak runner config:
docker run --rm -it -v gitlab-runner-vol:/etc/gitlab-runner debian
apt update
apt install nano
nano /etc/gitlab-runner/config.toml
- add
pull_policy = "if-not-present"
to runner config, i.e.:
[[runners]]
...
executor = "docker"
...
[runners.docker]
...
pull_policy = "if-not-present" # pull docker images on demand and not always
- Create and run container (using a WSL2 Linux shell):
docker run -d --name gitlab-runner --restart always \
-v gitlab-runner-vol:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /usr/bin/com.docker.cli:/usr/bin/com.docker.cli \
gitlab/gitlab-runner:latest
/var/run/docker.sock
must be read-/writeable for all, sochmod 666 /var/run/docker.sock
as root on the host if necessary- only works this way, if Docker uses WSL2 back-end
- otherwise, GitLab Runner should be installed locally and not in a container
- If the runner is not needed anymore, stop and remove the container and volume:
docker stop gitlab-runner
docker rm gitlab-runner
docker volume rm gitlab-runner-vol
- Create and run a container for hosting the servlet using Tomcat:
docker run -d --name github-runner -p 8081:8080 tomcat:9.0.46-jdk11
- Open a shell in the container:
docker exec -it github-runner /bin/bash
- Install Maven in the container:
apt update
apt install maven
- Change permissions on
/usr/local/tomcat/webapps
to world read-/writeable:
chmod 777 /usr/local/tomcat/webapps
- Create a new user for running the GitHub self-hosted runner and switch to that user:
adduser github-runner
su -l github-runner
-
Install and run self-hosted runner for Linux X64 as explained in the settings of your repository (Settings → Actions → Runners)
-
To stop the runner, press
Ctrl + C
. -
If the runner is not needed anymore,
exit
the container shell and then stop and remove the container:
docker stop github-runner
docker rm github-runner