Orange Lux
Orange Lux

Reputation: 2037

Docker not found on gitlab-ci shell on Windows 10

I'm developing an API on Windows 10 using Docker. I've hosted my code on a gitlab free plan, and I'm trying to setup a gitlab-ci pipeline.

I've installed both powershell and the gitlab-runner on my machine, and I have a runner set up to be ran on my local machine (config.toml):

concurrent = 1
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "my-runner"
  url = "https://gitlab.com"
  id = [redacted]
  token = "[redacted]"
  token_obtained_at = 2024-09-27T11:22:39Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  shell = "pwsh"
  [runners.custom_build_dir]
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

I understood that the runner will be triggered by gitlab, and run the gitlab-ci steps on my local machine.

I've tried running the example config and it works.

But when I create my own config (which validates with the validation tool), I've got an error.

Here's part of my config (.gitlab-ci.yml) :

php-cs-fixer:
  stage: build
  script:
    - docker compose run --file C:\path\to\docker-compose.yml --rm php tools/php-cs-fixer/vendor/bin/php-cs-fixer check

That's a command I can run on my machine in any directory and it will succeed. But on the pipeline, I've got this error:

Running with gitlab-runner 17.4.0~pre.110.g27400594 (27400594)
  on [redacted].gitlab.com/default [redacted], system ID: [redacted]
Preparing the "docker+machine" executor 00:21
Using Docker executor with image ruby:3.1 ...
Pulling docker image ruby:3.1 ...
Using docker image sha256:12bc18a740469918b597219b1033d2fd4a60594a8ada2ec29383f64e39e8df0b for ruby:3.1 with digest ruby@sha256:0a169917faf10879c7c02685b5034f7ae8da08191580ab8f15f2bb346ee87ec9 ...
Preparing environment 00:04
Running on runner-[redacted]-concurrent-0 via runner-zxwgkjap-s-l-s-amd64-1727439752-32adb9d7...
Getting source from Git repository 00:02
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/[repository_name]/.git/
Created fresh repository.
Checking out d47fc44d as detached HEAD (ref is cicd)...
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
Executing "step_script" stage of the job script 00:00
Using docker image sha256:12bc18a740469918b597219b1033d2fd4a60594a8ada2ec29383f64e39e8df0b for ruby:3.1 with digest ruby@sha256:0a169917faf10879c7c02685b5034f7ae8da08191580ab8f15f2bb346ee87ec9 ...
$ docker compose --file C:\path\to\docker-compose.yml run --rm php tools/php-cs-fixer/vendor/bin/php-cs-fixer check
/usr/bin/bash: line 147: docker: command not found
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1

It seems like the docker command triggers the installation of a docker image on the runner ?

Have I misconfigured something? Or misunderstood anything?

How can I execute the docker command on my machine from the pipeline ?

Upvotes: 2

Views: 138

Answers (1)

Gaël J
Gaël J

Reputation: 15295

GitLab CI runner exist with different types of executors.

From your logs Preparing the "docker+machine" executor it seems your runner is configured as a "docker machine" executor. Which spawns a specific isolated environment and not a shell directly on your laptop.

If we look even more at the logs, I'm pretty sure your runner on your laptop is not used at all. Running (...) on [redacted].gitlab.com/default. You should see your runner host/name here, not one from gitlab.com.

You should check in GitLab UI which runners are available to your project. You may use tags to restrict your jobs to run on a specific runner if needed.

Upvotes: 2

Related Questions