Upgrading to Docker Desktop 3.2.2 our tests using DockerComposeContainer started to fail when using docker-compose with dynamic ports. The error message is something like:
Timed out waiting for container port to open (localhost ports: [0, 55196] should be listening)
Debugging the code you can see that port 0 is reported and then ExternalPortListeningCheck fails because it tries to open a connection to localhost:0
As a workaround we are using this fix for HostPortWaitStrategy:
class HostPortWaitStrategyFixForDockerDesktop322 : HostPortWaitStrategy() {
override fun getLivenessCheckPorts(): MutableSet<Int> {
return super.getLivenessCheckPorts().stream()
.filter { port -> port > 0 }
.collect(Collectors.toSet())
}
}
And we use it like this:
container.withExposedService(SERVICE, SERVICE_PORT, HostPortWaitStrategyFixForDockerDesktop322())
Upgrading to Docker Desktop 3.2.2 our tests using DockerComposeContainer started to fail when using docker-compose with dynamic ports. The error message is something like:
Debugging the code you can see that port 0 is reported and then ExternalPortListeningCheck fails because it tries to open a connection to localhost:0
As a workaround we are using this fix for HostPortWaitStrategy:
And we use it like this: