-
Notifications
You must be signed in to change notification settings - Fork 27
Description
I’m currently trying to use WaitForHttp in the PHP Testcontainers SDK to wait until a specific HTTP route in my container becomes available.
The challenge I’m facing is that I have to provide a port number when calling WaitForHttp. However, the actual port mapped to the host is dynamically assigned at container startup. Since I don’t know this port in advance, I run into a chicken-and-egg problem: I need to configure WaitForHttp before starting the container, but the mapped port is only available after the container has been started.
In the Go and JavaScript SDKs, this problem is solved under the hood: WaitForHttp automatically resolves the mapped host port for the given internal container port. This allows you to use dynamic port mappings (which are often preferred to avoid hardcoding ports) without running into timing issues.
In the PHP SDK, however, I couldn’t find a way to do something similar. Maybe I’m missing something? Is there a recommended approach to wait for an HTTP endpoint when the host port is assigned dynamically?
Thanks in advance – and sorry if I’ve overlooked something obvious!