diff --git a/testcontainers/src/core/client.rs b/testcontainers/src/core/client.rs index 245f8ec4..eab92642 100644 --- a/testcontainers/src/core/client.rs +++ b/testcontainers/src/core/client.rs @@ -421,6 +421,13 @@ impl Client { } pub(crate) async fn docker_hostname(&self) -> Result { + // allow TESTCONTAINERS_HOST_OVERRIDE to override the docker host + if let Some(host_override) = + ::get_env_value("TESTCONTAINERS_HOST_OVERRIDE") + { + return url::Host::parse(&host_override) + .map_err(|_| ConfigurationError::InvalidDockerHost(host_override).into()); + } let docker_host = &self.config.docker_host(); let docker_host_url = Url::from_str(docker_host) .map_err(|e| ConfigurationError::InvalidDockerHost(e.to_string()))?;