I have a Windows EC2 instance in AWS, with Docker installed. I have two GitLab runners configured on this instance: a PowerShell runner (which runs jobs on the VM itself) and a Docker runner (that should run jobs using a container image specified in the .gitlab-ci.yml
I have a Windows container image, based on mcr.microsoft.com/dotnet/framework/sdk:4.7.2-20191008-windowsservercore-ltsc2019, with some additional tools installed.
When I try to build a simple console hello-world program using the container, I get this message as soon as the build starts:
ERROR: Job failed (system failure): prepare environment: Error response from daemon: invalid IP address in add-host: “172.27.84.100 172.27.82.245” (docker.go:651:0s). Check Types of shells supported by GitLab Runner | GitLab for more information
The two IP addresses listed in the error message do not match the IP address of the instance or its default gateway.
Based on the link in the error message, I verified that the OS version on the EC2 instance matches the OS version inside the container.
OS Name: Microsoft Windows Server 2019 Datacenter
OS Version: 10.0.17763 N/A Build 17763
I get the same error if I run a minimal .gitlab-ci.yml file that references a Microsoft-built container ( mcr.microsoft.com/windows/servercore:1809) and simply tries to execute a PowerShell command. This suggests that the problem is with Docker, rather than with the containers. The “add-host” in the error message suggests the “–add-host” option to the “docker run” command, which is supposed to “add a custom host-to-ip mapping” (per the Docker CLI documentation).
I can run containers manually from the command line on the instance (including the containers noted above); those containers start and behave normally.
As a test, I updated Docker from 19.03 (our standard version) to 20.10.7; this did not change the behavior.
Both the GitLab runner and the Docker service are running as users with Administrator rights on the instance.
I updated config.toml with log_level = “debug” and restarted the services, but I do not see any additional information in Event Viewer. The error happens so early in the process (failing to start the container) that there is no more information to be gained by increasing the log level.
One possibility I have not thoroughly explored: this EC2 instance was launched from an AMI built using Packer, with Docker installed during the Packer build process. It is possible that one of the IP addresses is one that the source instance had at the time that Packer was installing Docker on it. But if that were the case, I would expect to see at least one of the IP addresses in the error message be the same on different instances, and what I see is that both IP addresses change when I move to a new instance.
Here is the version information for gitlab-runner.exe:
Git revision: 98daeee0
Git branch: 14-7-stable
GO version: go1.17.5
Any advice would be greatly appreciated. Thanks in advance.