Cannot run gitlab-runner inside a windowsservercore container
Summary
Executing gitlab-runner run
inside a docker container "microsoft/windowsservercore" results in FATAL: The service process could not connect to the service controller.
Steps to reproduce
Create a docker container which contains the latest gitlab runner.
Dockerfile:
FROM microsoft/dotnet-framework:4.6.2
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && \
SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN choco install gitlab-runner -y
ADD register-gitlab-runner.ps1 .
CMD powershell .\register-gitlab-runner.ps1
register-gitlab-runner.ps1:
$Env:REGISTRATION_TOKEN = '<token>'
$Env:CI_SERVER_URL = '<url>'
$Env:RUNNER_TAG_LIST = 'windows, dotnetfull, vs2017, servicefabric'
$Env:RUNNER_NAME = "GitLab Runner (Windows) #${[guid]::NewGuid()}"
$Env:RUNNER_EXECUTOR = 'shell'
$Env:RUNNER_SHELL = 'powershell'
$Env:CONFIG_FILE = "${PWD}\config.toml"
$Env:REGISTER_RUN_UNTAGGED = 'false'
$Env:RUNNER_REQUEST_CONCURRENCY = 1
$Env:RUNNER_BUILDS_DIR = "${PWD}/builds"
$Env:RUNNER_CACHE_DIR = '${PWD}/cache'
gitlab-runner register --non-interactive
gitlab-runner run
gitlab-runner unregister --name $Env:RUNNER_NAME
Actual behavior
The run command results i a FATAL exception: "FATAL: The service process could not connect to the service controller."
Expected behavior
The run command starts and executes until SIG_TERM is received.
Relevant logs and/or screenshots
gitlab-runner run -d:
panic: reflect: call of reflect.Value.Type on zero Value [recovered]
panic: reflect: call of reflect.Value.Type on zero Value
goroutine 1 [running]:
panic(0x1488400, 0xc0423b1280)
/usr/local/go/src/runtime/panic.go:500 +0x1af
main.main.func1()
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/main.go:32 +0x86
panic(0x1488400, 0xc0423b1280)
/usr/local/go/src/runtime/panic.go:458 +0x251
reflect.Value.Type(0x0, 0x0, 0x0, 0xc0420101c0, 0xc0423537d0)
/usr/local/go/src/reflect/value.go:1670 +0x22b
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers.convertMarshal(0x0, 0x0, 0x0, 0x1, 0xc04247f2a0, 0xc042420080, 0xc04247f2e0, 0x53af0b)
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers/convert.go:47 +0x4a
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers.convertToString(0x0, 0x0, 0x0, 0x0, 0x0, 0x1579100, 0xc04237d980, 0x445788, 0x2dc62e6d1d9)
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers/convert.go:58 +0x64
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers.StructFieldValue.String(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers/struct_field.go:32 +0x82
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/gitlab.com/ayufan/golang-cli-helpers.(*StructFieldValue).String(0xc04237d980, 0x1579100, 0xc04237d980)
<autogenerated>:5 +0x81
flag.isZeroValue(0xc04238ce00, 0xc0423b0f40, 0x1c, 0x1479b50)
/usr/local/go/src/flag/flag.go:393 +0x134
flag.(*FlagSet).PrintDefaults.func1(0xc04238ce00)
/usr/local/go/src/flag/flag.go:467 +0x1dc
flag.(*FlagSet).VisitAll(0xc0421a13e0, 0xc04247f588)
/usr/local/go/src/flag/flag.go:323 +0x6e
flag.(*FlagSet).PrintDefaults(0xc0421a13e0)
/usr/local/go/src/flag/flag.go:476 +0x56
flag.defaultUsage(0xc0421a13e0)
/usr/local/go/src/flag/flag.go:509 +0x9d
flag.(*FlagSet).usage(0xc0421a13e0)
/usr/local/go/src/flag/flag.go:825 +0x5c
flag.(*FlagSet).failf(0xc0421a13e0, 0x16842b7, 0x1b, 0xc04247f780, 0x1, 0x1, 0xc04247f738, 0x482765)
/usr/local/go/src/flag/flag.go:814 +0x11d
flag.(*FlagSet).parseOne(0xc0421a13e0, 0x7, 0xc0421a13e0, 0xc04209a070)
/usr/local/go/src/flag/flag.go:894 +0x5c8
flag.(*FlagSet).Parse(0xc0421a13e0, 0xc042031d90, 0x1, 0x1, 0x33603e8, 0x0)
/usr/local/go/src/flag/flag.go:915 +0x67
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/github.com/codegangsta/cli.Command.Run(0x1665dd6, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1681399, 0x18, 0x0, ...)
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/github.com/codegangsta/cli/command.go:98 +0xc3a
gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/github.com/codegangsta/cli.(*App).Run(0xc042340100, 0xc042031d70, 0x3, 0x3, 0x0, 0x0)
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/vendor/github.com/codegangsta/cli/app.go:159 +0x70c
main.main()
/go/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner/main.go:58 +0x256
Environment description
Windows Server 2016 DataCenter + Docker for Windows installed
Because of https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/2176, I tried to run several docker containers running gitlab-runner directly with shell executor.
Used GitLab Runner version
Version: 9.3.0 Git revision: 3df822b Git branch: 9-3-stable GO version: go1.7.5 Built: Thu, 22 Jun 2017 10:57:49 +0000 OS/Arch: windows/amd64