The GitLab CI runner failed because it couldn’t fulfill a prerequisite for the job, most commonly due to a missing or misconfigured Docker image.

Common Causes and Fixes

  1. Incorrect Docker Image Name or Tag:

    • Diagnosis: Check the image: directive in your .gitlab-ci.yml file. Verify the image name and tag exist on Docker Hub or your private registry. For example, if you have image: ubuntu:latest, ensure ubuntu:latest is a valid image.
    • Fix: Update the image: directive to a correct, existing image and tag. For instance, change image: ubuntu:latest to image: ubuntu:22.04 if latest is problematic or you need a specific version.
    • Why it works: The runner cannot pull or use an image that doesn’t exist. Specifying a valid, existing image allows the runner to download and use the correct environment for the job.
  2. Private Docker Registry Authentication Failure:

    • Diagnosis: If your CI job uses an image from a private registry (like GitLab Container Registry, Docker Hub private repos, AWS ECR, etc.), check if the runner has the necessary credentials. Look for CI_REGISTRY_USER, CI_REGISTRY_PASSWORD, and CI_REGISTRY variables in your CI/CD settings or .gitlab-ci.yml.
    • Fix: Ensure the runner is configured with the correct credentials for your private registry. This typically involves setting CI/CD variables in your project/group settings:
      • DOCKER_AUTH_CONFIG: A JSON string containing your registry credentials. Example for GitLab Container Registry:
        {"registry.gitlab.com":{"auth":"<base64_encoded_username:password>"}}
        
        You can generate the auth part using echo -n "your_username:your_password" | base64.
      • Alternatively, use project-specific variables like CI_REGISTRY_USER, CI_REGISTRY_PASSWORD, and CI_REGISTRY if your .gitlab-ci.yml explicitly references them for docker login.
    • Why it works: The runner needs to authenticate with the private registry before it can pull private images. Correctly configured credentials allow this authentication, granting access to the specified image.
  3. Runner Not Registered or Tags Mismatch:

    • Diagnosis: In your .gitlab-ci.yml, you might specify a tags: for a job. Ensure at least one registered runner has a matching tag. Check Settings -> CI/CD -> Runners in your GitLab project to see available runners and their tags. Also, verify the runner’s configuration (/etc/gitlab-runner/config.toml) for its assigned tags.
    • Fix: Either update the tags: in your .gitlab-ci.yml to match an existing runner’s tag, or register a new runner with the required tags, or add the missing tag to an existing runner’s configuration file (config.toml) and restart the runner service (sudo gitlab-runner restart).
    • Why it works: GitLab uses tags to route jobs to specific runners. If no runner has the specified tag, the job will never be picked up and will remain in a pending state with a "prerequisites not met" error.
  4. Insufficient Disk Space on Runner:

    • Diagnosis: If the runner is trying to pull a large Docker image or download large artifacts, it might run out of disk space. Check the runner’s disk usage (df -h) and specifically the Docker image storage location (often /var/lib/docker).
    • Fix: Free up disk space on the runner by removing unused Docker images (docker image prune -a -f), stopped containers (docker container prune -f), or old build artifacts. Consider increasing the disk size of the runner’s host if this is a recurring issue.
    • Why it works: Docker images and build artifacts require disk space. If the available space is exhausted during the download or extraction process, the job will fail.
  5. Network Connectivity Issues:

    • Diagnosis: The runner might be unable to reach the Docker registry (Docker Hub, private registry) or other external services required to fetch prerequisites. Try pinging the registry host from the runner machine.
    • Fix: Troubleshoot network connectivity from the runner. This might involve checking firewall rules, DNS resolution (nslookup registry.hub.docker.com), or proxy configurations on the runner machine or its network. Ensure the runner’s environment can access the necessary external resources.
    • Why it works: The runner needs a stable network connection to download Docker images and potentially other dependencies. Network interruptions or blocks prevent these downloads, leading to the prerequisite error.
  6. Docker Daemon Not Running or Unhealthy:

    • Diagnosis: The docker service on the runner machine might not be running, or it could be in an unhealthy state. Check its status with sudo systemctl status docker.
    • Fix: Start or restart the Docker daemon: sudo systemctl start docker or sudo systemctl restart docker. If it fails to start, check Docker logs (sudo journalctl -u docker.service) for specific error messages.
    • Why it works: Docker jobs rely on the Docker daemon to pull images, create containers, and manage the build environment. If the daemon is down, the runner cannot execute any Docker-related tasks.

The next error you’ll likely encounter, assuming all prerequisites are met, will be related to the actual execution of your build script within the container.

Want structured learning?

Take the full Gitlab-ci course →