Skip to content

Add custom host ip mapping to docker runner register command example.

Malcolm Locke requested to merge main-patch-9836 into main

What does this merge request do and why?

Following the instructions for setting up a docker runner on Linux currently fails because the container used to register the docker with the GDK instance is not aware of the local gdk.test host alias.

This MR updates the instructions to provide the host alias to the Docker command.

Steps to reproduce

On an Ubuntu Linux machine, follow the instructions for setting up a docker runner with GDK at https://gitlab.com/gitlab-org/gitlab-development-kit/blob/main/doc/howto/runner.md#docker-configuration

When the command at https://gitlab.com/gitlab-org/gitlab-development-kit/blob/main/doc/howto/runner.md#docker-configuration is run, it fails to lookup the host gdk.test as follows:

$ docker run --rm -it -v $(pwd):/etc/gitlab-runner gitlab/gitlab-runner register --url http://gdk.test:3000 --token <token> --config /etc/gitlab-runner/gitlab-runner-config.test.toml

Runtime platform                                    arch=amd64 os=linux pid=7 revision=436955cb version=15.11.0
Running in system-mode.                            
                                                   
Created missing unique system ID                    system_id=r_M3ns4QOEK9PO
Enter the GitLab instance URL (for example, https://gitlab.com/):
[http://gdk.test:3000]: 
Enter a name for the runner. This is stored only in the local config.toml file:
[cf181c262e02]: 
Enter an executor: instance, parallels, shell, virtualbox, docker-ssh, ssh, docker-autoscaler, docker+machine, docker-ssh+machine, custom, docker, docker-windows, kubernetes:
alpine:latest
ERROR: Invalid executor specified                  
Enter an executor: ssh, docker-autoscaler, docker+machine, docker-ssh+machine, custom, docker, docker-windows, docker-ssh, kubernetes, parallels, shell, virtualbox, instance:
[alpine:latest]: docker
Enter the default Docker image (for example, ruby:2.7):
alpine:latest
ERROR: Verifying runner... failed                   runner=D9iTs2zBv status=couldn't execute POST against http://gdk.test:3000/api/v4/runners/verify: Post "http://gdk.test:3000/api/v4/runners/verify": dial tcp: lookup gdk.test on 192.168.178.1:53: no such host
PANIC: Failed to verify the runner.

Running the command with an --add-host argument pointing to the correct IP address for GDK allows the command to succeed.

$ docker run --rm -it --add-host gdk.test:172.16.123.1 -v $(pwd):/etc/gitlab-runner gitlab/gitlab-runner register --url http://gdk.test:3000 --token <token> --config /etc/gitlab-runner/gitlab-runner-config.test.toml

Verifying runner... is valid                        runner=D9iTs2zBv
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
 
Configuration (with the authentication token) was saved in "/etc/gitlab-runner/gitlab-runner-config.test.toml"
Edited by Malcolm Locke

Merge request reports