3

I have a gitlab-runner on a Windows Server with enabled Hyper-V.

With the docker API exposed to the network I'm able to run linux docker containers and even docker itself with docker:latest.

e:\>docker run -ti --rm -e DOCKER_HOST=tcp://10.99.0.12:2375 --name test docker:latest

/ # docker ps
CONTAINER ID ....
xxxxx docker:latest ... Up 10 seconds

/ # docker run -ti --rm busybox uname -a
Linux 42342423 4.14.35 ... 

So that seems to be all correct.

When I now want to run a docker-compose up -d in my deploy stage, I'll get an error from gitlab-runner

Running with gitlab-runner 12.10.0 (c553af1a)
   on Staging Runner
Preparing the "docker" executor
 ERROR: Removing network for build
 ERROR: Job failed: executor requires OSType=linux, but Docker Engine supports only OSType=windows

I maybe could run gitlab-runner directly on the host machine, but rather have everything in the repository and only need to have docker installed.

Meiko Watu
  • 451
  • 1
  • 4
  • 11

2 Answers2

1

I've run into this recently. You have to go into Docker on your Windows host and select the "Switch to Linux containers..." option.

Related:

Aleksey Tsalolikhin
  • 1,518
  • 7
  • 14
  • unfortunately not the missing point here. I can run linux containers without problems, see above. I'm also on windows server and LCOW_SUPPORTED environment variable is set to 1 – Meiko Watu Apr 29 '20 at 16:35
  • And the gitlab-runner instance i'm running is also a linux based image – Meiko Watu Apr 29 '20 at 16:36
  • My bad. I'm a little confused, why aren't you using the Windows GitLab Runner if you are running the runner on Windows? (https://docs.gitlab.com/runner/install/windows.html) Or, to put it another way, if you're running Linux containers only, why do it on a Windows server? – Aleksey Tsalolikhin Apr 29 '20 at 16:46
  • 1
    Since it's a Windows server installation for a customer, I don't have much say in it. And I wanted a setup which doesn't much depend on locally installed and configured applications. Rather start one docker container and the rest is in code in the CI. But seems I don't have much other choice than switch to Windows runner, since it seems not be supported by gitlab-runner. https://gitlab.com/gitlab-org/gitlab-runner/-/blob/38c4da280fbc2102f8aab2892798b0b99438afa7/executors/docker/docker.go#L1049 – Meiko Watu Apr 29 '20 at 17:54
  • Right, that makes sense. Thanks! – Aleksey Tsalolikhin Apr 29 '20 at 20:15
1

For everyone coming across this with the same problem.

Gitlab doesn't want to implement LCOW at the moment so it's not possible with docker-executor.

More info: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4373

Meiko Watu
  • 451
  • 1
  • 4
  • 11