Why do we need to specify the executor when using gitlab-runner exec?

I have registered a local gitlab runner with the docker executor, such that when I go into /etc/gitlab-runner/config.toml, I see this:

[[runners]]
  ...
  executor = "docker"
  ...

When I need to locally test a specific job named <job_name>, I run this:

sudo gitlab-runner exec docker <job_name>

My question is why do I need to specify the executor again (docker) if this runner was already registered as a docker runner? Does the docker coming after the exec refer to something different than the docker in runners.executor?

The exec call is a local run only, so it dont contact the daemon which maybe run on the same machine and that is the reason why you have to specify the executor „again“. You can also use another excutor on the same machine which is not registered.

Checkout the docs about the limitations and more infos about exec.

Greetings

Tonka