Skip to content

Services using windows containers do not pass health check and are not working

Summary

When using windows container based services, the service health check fails with: FATAL: No HOST or PORT found. The service cannot be used. A similar job works on linux

Steps to reproduce

Run the following two jobs on a runner with executor docker-windows for the test-win job and docker for the test-lnx job.

.gitlab-ci.yml
test-win:
  services:
    - name: caddy:2.7.6-windowsservercore-ltsc2022
      alias: myservice
  image:
    name: mcr.microsoft.com/windows/servercore:ltsc2022
  script:
    - curl myservice


test-lnx:
  services:
    - name: caddy:2.7.6
      alias: myservice
  image:
    name: curlimages/curl
  script:
    - curl myservice

Actual behavior

The service on Windows does not pass the health check and the service is not available during the job execution.

Using docker ps on the build node, I can see that the service container is started and running, but it does not get the appropriate name/alias so the job container cannot reach the service container by name. This might also be the reason why the health check fails.

Expected behavior

Service is running, health check passes and is reachable from the job container like on Linux.

Relevant logs and/or screenshots

job log Windows
Using Docker executor with image mcr.microsoft.com/windows/servercore:ltsc2022 ...
Starting service caddy:2.7.6-windowsservercore-ltsc2022 ...
Pulling docker image caddy:2.7.6-windowsservercore-ltsc2022 ...
Using docker image sha256:33367b5c991e5b0e4f4752a83d92a2427c6e9d98fbfdf37769b0924602a0139c for caddy:2.7.6-windowsservercore-ltsc2022 with digest caddy@sha256:cdb4600df8fe3e27d97f1fb21ba9d5fdb1bd8198a1f025ca2458154f28d76934 ...
Waiting for services to be up and running (timeout 30 seconds)...
*** WARNING: Service runner-td8jeelf-project-4119-concurrent-0-d23eed8e810c2232-caddy-0 probably didn't start properly.
Health check error:
service "runner-td8jeelf-project-4119-concurrent-0-d23eed8e810c2232-caddy-0-wait-for-service" health check: exit code 1
Health check container logs:
2024-02-02T13:15:37.878087300Z FATAL: No HOST or PORT found                      
Service container logs:
2024-02-02T13:15:35.194824300Z {"level":"info","ts":1706879735.1948242,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
2024-02-02T13:15:35.205532200Z {"level":"info","ts":1706879735.205532,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
2024-02-02T13:15:35.206039100Z {"level":"info","ts":1706879735.205532,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00048c480"}
2024-02-02T13:15:35.206039100Z {"level":"warn","ts":1706879735.205532,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
2024-02-02T13:15:35.206643400Z {"level":"info","ts":1706879735.2061336,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
2024-02-02T13:15:35.207414200Z {"level":"warn","ts":1706879735.2061336,"logger":"tls","msg":"unable to get instance ID; storage clean stamps will be incomplete","error":"open c:\\data\\caddy\\instance.uuid: The system cannot find the path specified."}
2024-02-02T13:15:35.207414200Z {"level":"info","ts":1706879735.2074144,"msg":"autosaved config (load with --resume flag)","file":"c:\\config\\caddy\\autosave.json"}
2024-02-02T13:15:35.207414200Z {"level":"info","ts":1706879735.2074144,"msg":"serving initial configuration"}
2024-02-02T13:15:35.210093900Z {"level":"info","ts":1706879735.2095652,"logger":"tls","msg":"cleaning storage unit","storage":"FileStorage:c:\\data\\caddy"}
2024-02-02T13:15:35.210629600Z {"level":"info","ts":1706879735.2106006,"logger":"tls","msg":"finished cleaning storage units"}

Environment description

On-premise Gitlab and gitlab-runners.

config.toml contents
[[runners]]
  name = "docker-win"
  url = "https://gitlab...../"
  executor = "docker-windows"
  shell = "pwsh"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    image = "hello-world"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    shm_size = 0

Used GitLab Runner version

Version:      16.7.0
Git revision: 102c81ba
Git branch:   16-7-stable
GO version:   go1.20.10
Built:        2023-12-21T17:01:29+0000
OS/Arch:      windows/amd64