diff --git a/Ductus.FluentDocker/Extensions/CommandExtensions.cs b/Ductus.FluentDocker/Extensions/CommandExtensions.cs index 11bddd1..de43d8c 100644 --- a/Ductus.FluentDocker/Extensions/CommandExtensions.cs +++ b/Ductus.FluentDocker/Extensions/CommandExtensions.cs @@ -161,23 +161,33 @@ public static bool IsEmulatedNative() } +#if NETSTANDARD1_6 public static bool IsDockerDnsAvailable() { try { -#if NETSTANDARD1_6 Dns.GetHostEntryAsync("host.docker.internal").Wait(); + return true; + } + catch (Exception ex) when (ex.GetBaseException() is SocketException) + { + return false; + } + } #else + public static bool IsDockerDnsAvailable() + { + try + { Dns.GetHostEntry("host.docker.internal"); -#endif return true; } - catch (AggregateException ex) - when (ex.InnerExceptions.Count == 1 && ex.InnerExceptions[0] is SocketException) + catch (SocketException) { return false; } } +#endif public static bool IsNative() {