Gitlab is telling me that i have no active runners

I’m trying to learn how to use GitLab CI. I got GitLab to work on my local computer using Docker-compose. This is my docker-compose.yml

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'MY.HOSTNAME.COM'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://MY.HOSTNAME.COM'
      gitlab_rails['smtp_enable'] = true
      gitlab_rails['smtp_address'] = "smtp.mailgun.org"
      gitlab_rails['smtp_port'] = 587
      gitlab_rails['smtp_authentication'] = "plain"
      gitlab_rails['smtp_enable_starttls_auto'] = true
      gitlab_rails['smtp_user_name'] = "postmaster@MY.HOSTNAME.COM"
      gitlab_rails['smtp_password'] = "MY_PASSWORD"
      gitlab_rails['smtp_domain'] = "email.MY.HOSTNAME.COM"
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
  ports:
    - '80:80'
    - '443:443'
    - '2224:22'
  volumes:
    - '/home/ignacio/gitlab/config:/etc/gitlab'
    - '/home/ignacio/gitlab/logs:/var/log/gitlab'
    - '/home/ignacio/gitlab/data:/var/opt/gitlab'

Then I followed this tutorial to install GitLab Runner using docker on the same machine. This is what my local GitLab instance is showing me now:

This is the configuration page for the runner:

Alas, for some reason it is not working:

What did I do wrong?

Thanks!

1 Like

hello,

One question, when you registered the runner, do you use clause this?

 --run-untagged="true"\
  --locked="false"

or exactly how do you registered the runner?

This is what i ran:

docker run -d --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

To register the runner i ran:

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register

I also tried:

    docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register \
  --non-interactive \
  --executor "docker" \
  --docker-image alpine:3 \
  --url "https://MY.HOSTNAME.COM" \
  --registration-token "MY_TOKEN" \
  --description "docker-runner" \
  --run-untagged="true" \
  --locked="false"

But this did not help either

Can you run this to see if there is an error?
“docker logs -f --tail=100 gitlab-runner”

ignacio@ignacio-XPS-8930:~$ docker logs -f --tail=100 gitlab-runner
Starting multi-runner from /etc/gitlab-runner/config.toml ...  builds=0
Running in system-mode.                            
                                                   
Configuration loaded                                builds=0
Listen address not defined, metrics server disabled  builds=0
Listen address not defined, session server disabled  builds=0
ERROR: Checking for jobs... forbidden               runner=f39770ba
ERROR: Checking for jobs... forbidden               runner=f39770ba
ERROR: Checking for jobs... forbidden               runner=f39770ba
ERROR: Runner https://MY_HOST/f39770ba067ca116f29beecf5bd396 is not healthy and will be disabled! 

Can you verify if ip you have ip forwarding enabled on your host?

“sysctl net.ipv4.ip_forward”

ignacio@ignacio-XPS-8930:~$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

As the runner is apparently not getting an ip address, you can try the following:

Verify if a created user network exists:

docker network ls

If it does not exist it can be created in the following way:

docker network create --driver=bridge --subnet=172.18.0.0/24 --gateway=172.20.0.1 runner-net

In the docker-compose file the network_mode clause is added or if it is by docker run it would be --net

compose–

network_mode: "runner-net"

run

docker run --net="runner-net" ....

ignacio@ignacio-XPS-8930:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
2eab2a270784        bridge              bridge              local
ce2643a4e2be        host                host                local
e99e945e9947        none                null                local
f918fd97d7c9        shinyproxy-net      bridge              local
ignacio@ignacio-XPS-8930:~$ 
ignacio@ignacio-XPS-8930:~$ docker network create --driver=bridge --subnet=172.18.0.0/24 --gateway=172.20.0.1 runner-net
no matching subnet for gateway 172.20.0.1

I’m sorry, use --subnet = 172.20.0.0/24 instead of --subnet = 172.18.0.0/24

This is what i got

ignacio@ignacio-XPS-8930:~$ docker network create --driver=bridge --subnet=172.20.0.0/24 --gateway=172.20.0.1 runner-net
35a7b808ab2bdf07b753f8ccec67d9d6dc8ce19cd3eb6567357e5beadaa0db90

PS: Thanks a lot for the help!

Is the runner already functioning?

With all the things i tried the runner is not currently functioning. What is the best way to get it up and running:

A.

docker run -d --name gitlab-runner --restart always \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

and then

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register

or

B.

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register \
  --non-interactive \
  --executor "docker" \
  --docker-image alpine:3 \
  --url "https://MY.HOSTNAME.COM" \
  --registration-token "MY_TOKEN" \
  --description "docker-runner" \
  --run-untagged="true" \
  --locked="false"

or something else?

add the network that you created

with docker-compose:

network_mode: runner-net

with docker run:

docker run ..... --network=runner-net ...

Sorry. I’m very new to this so i’m not sure exactly what i’m supposed to do. This is what I tried:

I modified the docker-compose.yml for my gitlab instance

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'MY.HOSTNAME.COM'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://MY.HOSTNAME.COM'
      gitlab_rails['smtp_enable'] = true
      gitlab_rails['smtp_address'] = "smtp.mailgun.org"
      gitlab_rails['smtp_port'] = 587
      gitlab_rails['smtp_authentication'] = "plain"
      gitlab_rails['smtp_enable_starttls_auto'] = true
      gitlab_rails['smtp_user_name'] = "postmaster@MY.HOSTNAME.COM"
      gitlab_rails['smtp_password'] = "MY_PASSWORD"
      gitlab_rails['smtp_domain'] = "email.MY.HOSTNAME.COM"
      gitlab_rails['gitlab_shell_ssh_port'] = 2224
  ports:
    - '80:80'
    - '443:443'
    - '2224:22'
  network_mode: runner-net
  volumes:
    - '/home/ignacio/gitlab/config:/etc/gitlab'
    - '/home/ignacio/gitlab/logs:/var/log/gitlab'
    - '/home/ignacio/gitlab/data:/var/opt/gitlab'

I ran docker-compose up -d

ignacio@ignacio-XPS-8930:~/docker/gitlab$ docker-compose up -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for web: 'network_mode'

I removed that change

I ran:

ignacio@ignacio-XPS-8930:~/docker/gitlab$ docker-compose up -d
Creating gitlab_web_1 ... 
Creating gitlab_web_1 ... done

I ran:

docker run -d --name gitlab-runner --restart always \
  --net="runner-net" \
  -v /srv/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

I ran:

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register \
  --non-interactive \
  --executor "docker" \
  --docker-image alpine:3 \
  --url "https://MY.HOSTNAME.COM" \
  --registration-token "MY_TOKEN" \
  --description "docker-runner" \
  --run-untagged="true" \
  --locked="false"

I can see the runner on my gitlab

But it is stuck

Just to be clear, I think your conclusion answer is too confuse.
After register the network, I just executed one command at all.

Create a network

docker network create --driver=bridge --subnet 172.20.0.0/24 --gateway=172.20.0.1 runner-net

Register a runner

You last answer worked for me with some changes:

sudo docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name my-runner-name gitlab/gitlab-runner:alpine register \
  --non-interactive \
  --executor "docker" \
  --docker-image alpine:latest \
  --url "https://gitlab.com/" \
  --registration-token "MY_TOKEN" \
  --description "docker-runner" \
  --run-untagged="true" \
  --locked="false"

Here some changes have been made:

  • --locked to true will lock the runner to a project
  • --docker-image should be alpine:latest
  • gitlab/gitlab-runner:alpine register should be alpine as well

More details here:

https://docs.gitlab.com/runner/register/#one-line-registration-command

In case the runner don’t start automatically

But now I cannot start automatically more than one runner. The other one don’t start.

So, try to remove the runner as below:

docker stop my-gitlab-runner-name && sudo docker rm my-gitlab-runner-name

And run it again using the follow command:

docker run -d --name my-gitlab-runner-name --restart always --net="runner-net" -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:alpine

Than you can check in the logs if it’s okay now using docker logs my-gitlab-runner-name command:

Runtime platform                                    arch=amd64 os=linux pid=7 revision=577f813d version=12.5.0
Starting multi-runner from /etc/gitlab-runner/config.toml ...  builds=0
Running in system-mode.                            
                                                   
Configuration loaded                                builds=0
Locking configuration file                          builds=0 file=/etc/gitlab-runner/config.toml pid=7
listen_address not defined, metrics & debug endpoints disabled  builds=0
[session_server].listen_address not defined, session endpoints disabled  builds=0

I had the same problem. In my case it was i specific runner and i just attach the “tags” list in my gitlab-ci.yml to my specific runner.

1 Like