First, configure the environment parameters:
cp docker/gitlab/env.example.gitlab-gitlabci.txt docker/gitlab/gitlab-gitlabci.env
vi docker/gitlab/gitlab-gitlabci.env
Run the following command to start GitLab and a GitLab Runner in a Docker container:
docker compose -f docker/gitlab-gitlabci.yml --env-file docker/gitlab/gitlab-gitlabci.env up --build -d
Then log on to http://localhost/ with the password (sudo docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password
) and go to http://localhost/admin/runners.
Click on "Register an instance runner" and copy the registration token.
Open a shell into the gitlab-runner
container:
docker exec -it gitlab-runner /bin/bash
Execute the following command with your token inside the container with the registration token generated above (If you use Linux, try --clone-url http://172.17.0.1:80 \
, because gateway.docker.internal
is only for Windows):
gitlab-runner register \
--non-interactive \
--executor "docker" \
--docker-image alpine:latest \
--url http://gitlab:80 \
--clone-url http://gateway.docker.internal:80 \
--registration-token "PROJECT_REGISTRATION_TOKEN" \
--description "docker-runner" \
--maintenance-note "Just a random local test runner" \
--tag-list "docker,artemis" \
--run-untagged="true" \
--locked="false" \
--access-level="not_protected"
If you experience problems while installing or registering the runner, you can have a look at the documentation for docker (https://docs.gitlab.com/runner/install/docker.html, https://docs.gitlab.com/runner/register/index.html#docker)