GitLab Runner
What is GitLab Runner?
GitLab Runner is the agent that picks up and executes jobs defined in a project's .gitlab-ci.yml. It pairs with the GitLab service: GitLab schedules pipelines, the runner actually executes them.
Start GitLab Runner
docker compose up -d gitlab-runner
Stop GitLab Runner
docker compose stop gitlab-runner
Configuration
All settings live in gitlab-runner/defaults.env and can be overridden by adding the same line to your own .env (your .env always wins):
| Variable | Default | What it does |
|---|---|---|
GITLAB_CI_SERVER_URL | http://localhost:8989 | URL of the GitLab instance the runner registers against. |
GITLAB_RUNNER_REGISTRATION_TOKEN | <my-registration-token> | Token from your GitLab project used to register the runner. |
GITLAB_REGISTER_NON_INTERACTIVE | true | Runs gitlab-runner register without prompting when set. |
By default gitlab-runner/compose.yml runs the runner with RUNNER_EXECUTOR=shell. It also mounts /var/run/docker.sock, so you can switch to a Docker executor instead (see below).
Register the runner against GitLab
- In your GitLab project, go to Settings → CI/CD → Runners and copy the registration token.
- Set these in
.env(use the container name, notlocalhost, since the runner talks to GitLab over the Docker network):GITLAB_DOMAIN_NAME=http://gitlabGITLAB_RUNNER_REGISTRATION_TOKEN=<value-from-step-1>GITLAB_CI_SERVER_URL=http://gitlab - To use the Docker executor instead of the default shell executor, add this to
gitlab-runner/compose.yml:gitlab-runner:environment: # used during `gitlab-runner register`- RUNNER_EXECUTOR=docker # change from shell (default)- DOCKER_IMAGE=alpine- DOCKER_NETWORK_MODE=laradock_backendnetworks:- backend # connect to the network where gitlab runs - Start the runner:
docker compose up -d gitlab-runner
- Register it:
docker compose exec gitlab-runner bashgitlab-runner register
- Add a
.gitlab-ci.ymlto your project, push, and confirm the pipeline runs:before_script:- echo Hello!job1:scripts:- echo job1
Common issues
- Runner registers but jobs never pick up. Confirm
GITLAB_CI_SERVER_URLpoints to a URL the runner container can actually reach,http://gitlab(container name), nothttp://localhost. REGISTRATION_TOKENrejected. Tokens are per-project (or per-group/instance depending on your GitLab setup) and can be regenerated in GitLab's Settings → CI/CD → Runners, grab a fresh one if registration fails.- Docker-executor jobs can't reach other Laradock services. Make sure
DOCKER_NETWORK_MODEmatches your actual Compose project's network name (laradock_backendby default, but it's prefixed byCOMPOSE_PROJECT_NAME). - Re-registering after changing executors. Changing
RUNNER_EXECUTORafter the runner is already registered doesn't retroactively apply, re-rungitlab-runner register(or clearDATA_PATH_HOST/gitlab/runnerand start fresh).
Need the GitLab server this runner connects to? See GitLab. New to Laradock? Start at Getting Started.