testcontainers / testcontainers-dotnet

A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
https://dotnet.testcontainers.org
MIT License
3.73k stars 264 forks source link

[Bug]: Keycloak health endpoint is in port 9000 on "quay.io/keycloak/keycloak:25.0.1" #1208

Closed paulomorgado closed 1 month ago

paulomorgado commented 2 months ago

Testcontainers version

3.9.0

Using the latest Testcontainers version?

Yes

Host OS

Windows

Host arch

x64

.NET version

8.0.300

Docker version

Client:
 Version:           26.1.0-rd
 API version:       1.44 (downgraded from 1.45)
 Go version:        go1.21.9
 Git commit:        cca8e72
 Built:             Tue Apr 23 16:26:59 2024
 OS/Arch:           windows/amd64
 Context:           default

Server:
 Engine:
  Version:          25.0.5
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.10
  Git commit:       e63daec8672d77ac0b2b5c262ef525c7cf17fd20
  Built:            Sun May 12 07:25:43 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.7.10
  GitCommit:        4e1fe7492b9df85914c389d1f15a3ceedbb280ac
 runc:
  Version:          1.1.12
  GitCommit:        51d5e94601ceffbbd85688df1c928ecccbfa4685
 docker-init:
  Version:          0.19.0
  GitCommit:

Docker info

Client:
 Version:    26.1.0-rd
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.0
    Path:     C:\Users\paulo.morgado\.docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.23.3
    Path:     C:\Users\paulo.morgado\.docker\cli-plugins\docker-compose.exe

Server:
 Containers: 2
  Running: 2
  Paused: 0
  Stopped: 0
 Images: 41
 Server Version: 25.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 4e1fe7492b9df85914c389d1f15a3ceedbb280ac
 runc version: 51d5e94601ceffbbd85688df1c928ecccbfa4685
 init version:
 Security Options:
  seccomp
   Profile: builtin
 Kernel Version: 5.15.153.1-microsoft-standard-WSL2
 Operating System: Rancher Desktop WSL Distribution
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 7.761GiB
 Name: PT33N7SG3
 ID: 611e69e8-d198-4d27-a2cb-346f96550216
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

What happened?

When using "quay.io/keycloak/keycloak:25.0.1" image, the container is never detected as started because the health endpoint is on port 9000 and not on port 8080.

Relevant log output

No response

Additional information

As a workaround, I'm using this:

var keycloak = new KeycloakBuilder()
    .WithImage("quay.io/keycloak/keycloak:25.0.1")
    // ...
    .WithPortBinding(9000, true)
    .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => request.ForPath("/health/ready").ForPort(9000)))
    .Build();
HofmeisterAn commented 1 month ago

Thanks for creating the issue. Do you know in which version the port for the health check was changed? The module uses version 21. We will need the wait strategy to distinguish between the old and new versions.

paulomorgado commented 1 month ago

@HofmeisterAn,

Thanks for creating the issue. Do you know in which version the port for the health check was changed? The module uses version 21. We will need the wait strategy to distinguish between the old and new versions.

I couldn't find that information.

I just pulled the 24.0.5 and 25.0.0 and the change seems to be starting with 25.0.0.

https://www.keycloak.org/server/management-interface states that there's a configuration for that:

http-management-port Port of the management interface. CLI: --http-management-port Env: KC_HTTP_MANAGEMENT_PORT Available only when Management interface is enabled

I just did some limited testing and it seems to work on port 8080, if you add:

.WithEnvironment("KC_HTTP_MANAGEMENT_PORT", "8080")

Edit: The test passed, but the health endpoints are not responding on port 8080. I'm not that experienced in Keycloak. 😄