From 8749b52e1f264d4be17874d56fa24d24b4a1bea2 Mon Sep 17 00:00:00 2001 From: Mario Toffia Date: Wed, 8 Dec 2021 19:21:16 +0100 Subject: [PATCH] when "standard" daemon addresses in use skip -H This allows the docker-compose v2 to work properly. Need to introduce docker contexts thogh :) --- .vscode/settings.json | 21 ++++++++++++------- .../Extensions/CommandExtensions.cs | 6 +++--- Ductus.FluentDocker/Model/Common/DockerUri.cs | 11 ++++++++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 088f113..48b9296 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,31 +1,33 @@ { "cSpell.words": [ - "Ductus", - "Exploaded", - "Ipam", - "LOCALAPPDATA", - "Miscellanious", - "NOPASSWD", - "Npgsql", - "Toffia", "appconfig", "archve", "behaviour", "compsed", + "cref", "dont", + "Ductus", "editorconfig", + "Exploaded", "flaviours", "fluentdockerdl", "fluentdockertest", + "Imageverficiation", + "Ipam", "kiasaki", + "LOCALAPPDATA", "lxss", "mariotoffia", "martoffi", + "Miscellanious", "mkdir", "myimg", "mysecretpassword", "mytag", "nodetest", + "NOPASSWD", + "Npgsql", + "npipe", "nuget", "particulary", "postgres", @@ -34,6 +36,9 @@ "proto", "somewordpress", "sudoer", + "tlscacert", + "tlscert", + "Toffia", "typeof", "wdlp" ], diff --git a/Ductus.FluentDocker/Extensions/CommandExtensions.cs b/Ductus.FluentDocker/Extensions/CommandExtensions.cs index de43d8c..bf4af16 100644 --- a/Ductus.FluentDocker/Extensions/CommandExtensions.cs +++ b/Ductus.FluentDocker/Extensions/CommandExtensions.cs @@ -22,7 +22,7 @@ public static class CommandExtensions /// /// Reads a until is set to true - /// or a timeout occured on a read. + /// or a timeout occurred on a read. /// /// The type of returned items in the console stream. /// The stream to read from. @@ -214,10 +214,10 @@ public static IPAddress EmulatedNativeAddress(bool useCache = true) return _cachedDockerIpAddress; } - internal static string RenderBaseArgs(this Uri host, ICertificatePaths certificates = null) + internal static string RenderBaseArgs(this DockerUri host, ICertificatePaths certificates = null) { var args = string.Empty; - if (null != host) + if (null != host && !host.IsStandardDaemon) { args = $" -H {host}"; } diff --git a/Ductus.FluentDocker/Model/Common/DockerUri.cs b/Ductus.FluentDocker/Model/Common/DockerUri.cs index c8d0688..1344079 100644 --- a/Ductus.FluentDocker/Model/Common/DockerUri.cs +++ b/Ductus.FluentDocker/Model/Common/DockerUri.cs @@ -13,6 +13,8 @@ public sealed class DockerUri : Uri public DockerUri(string uriString) : base(uriString) { + if (uriString == DockerHostUrlMacOrLinux || uriString == DockerHostUrlWindowsNative) + this.IsStandardDaemon = true; } public static string GetDockerHostEnvironmentPathOrDefault() @@ -31,6 +33,15 @@ public static string GetDockerHostEnvironmentPathOrDefault() return CommandExtensions.IsToolbox() ? DockerHostUrlLegacy : DockerHostUrlMacOrLinux; } + /// + /// Returns true if the DockerUri has a "standard" daemon URI. + /// + /// True if standard daemon, false otherwise. + /// + /// If it is a standard daemon URI, there's no need to add the -H flag + /// + public bool IsStandardDaemon {get;} + public override string ToString() { var baseString = base.ToString();