Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct default for get_host_ip_address in case of unix or npipe #613

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testcontainers/src/core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl Client {
.into_iter()
.filter_map(|ipam_cfg| ipam_cfg.gateway)
.next()
.unwrap_or_else(|| "localhost".to_string()),
.unwrap_or_else(|| "127.0.0.1".to_string()),
_ => unreachable!("docker host is already validated in the config"),
}
}
Expand Down
8 changes: 4 additions & 4 deletions testcontainers/src/core/containers/async_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ where

/// Returns the host ip address of docker container
pub async fn get_host_ip_address(&self) -> IpAddr {
self.docker_client
.docker_host_ip_address()
.await
let host_ip = self.docker_client.docker_host_ip_address().await;

host_ip
.parse()
.expect("invalid host IP")
.unwrap_or_else(|e| panic!("invalid host ip: '{host_ip}', error: {e}"))
}

pub async fn exec(&self, cmd: ExecCommand) {
Expand Down
4 changes: 2 additions & 2 deletions testcontainers/src/runners/sync_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ mod tests {
fn sync_run_command_should_expose_only_requested_ports() {
let image = GenericImage::new("hello-world", "latest");
let container = RunnableImage::from(image)
.with_mapped_port((123, 456))
.with_mapped_port((555, 888))
.with_mapped_port((124, 456))
.with_mapped_port((556, 888))
.start();

let container_details = inspect(container.id());
Expand Down
Loading