public Integer getServicePort(String serviceName, Integer servicePort) {
        Map<Integer, Integer> portMap = this.ambassadorPortMappings.get(getServiceInstanceName(serviceName));

        if (portMap == null) {
            throw new IllegalArgumentException(
                "Could not get a port for '" +
                serviceName +
                "'. " +
                "Testcontainers does not have an exposed port configured for '" +
                serviceName +
                "'. " +
                "To fix, please ensure that the service '" +
                serviceName +
                "' has ports exposed using .withExposedService(...)"
            );
        } else {
            return ambassadorContainer.getMappedPort(portMap.get(servicePort));
        }
    }
Get the port that an exposed service can be found at, from the host machine
(i.e. should be the machine that's running this Java process).
<p>
The service must have been declared using DockerComposeContainer#withExposedService.

@param serviceName the name of the service as set in the docker-compose.yml file.
@param servicePort the port exposed by the service container.
@return a port that can be used for accessing the service container.
core/src/main/java/org/testcontainers/containers/ComposeDelegate.java