Skip to content

Commit

Permalink
feat(#683): Return the gateway address of a network if one is assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Nov 25, 2022
1 parent 66ac453 commit 35c68d0
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/Testcontainers/Containers/TestcontainersContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,8 @@ private string GetContainerGateway()
return localhost;
}

var endpointSettings = this.container.NetworkSettings.Networks.TryGetValue("bridge", out var network) ? network : new EndpointSettings();
if (!string.IsNullOrWhiteSpace(endpointSettings.Gateway))
{
return endpointSettings.Gateway;
}

var networkSettings = this.container.NetworkSettings;
if (!string.IsNullOrWhiteSpace(networkSettings.Gateway))
{
return networkSettings.Gateway;
}

return localhost;
var endpointSettings = this.container.NetworkSettings.Networks.Values.FirstOrDefault();
return endpointSettings == null ? localhost : endpointSettings.Gateway;
}
}
}

0 comments on commit 35c68d0

Please sign in to comment.