This PR detects whether the running test is running in a Docker container and acts accordingly:
If the test is not in a Docker container, assume that it is running on the host. Then the usual process takes place: use localhost and the mapped port to connect to the container.
If the test is in a Docker container, assume it is running as a sibling container and that the docker command manages the same Docker engine (that's on the user to configure the container properly). Find and use the gateway IP address (which should represent the Docker host) and use the mapped port.
This is required as some CI engine may choose to (or be configured to) run the test in a container. As such, localhost won't be usable to connect to the container as it would represent the test container itself.
This PR detects whether the running test is running in a Docker container and acts accordingly:
localhost
and the mapped port to connect to the container.docker
command manages the same Docker engine (that's on the user to configure the container properly). Find and use the gateway IP address (which should represent the Docker host) and use the mapped port.This is required as some CI engine may choose to (or be configured to) run the test in a container. As such,
localhost
won't be usable to connect to the container as it would represent the test container itself.