Skip to content

Support other docker-compatible container engines (e.g. finch) #315

Open
@georgearnall

Description

@georgearnall

Somewhat related to #300. I see that there are some users that are using this package with different container runtimes (finch, podman etc).

There is a workaround for mapping these engines to the 'docker' binary with an alias, however this is not recommended by the maintainers of these projects.

It would be great if there was a way to override the binary that the library uses.

private static IEnumerable<DockerBinary> ResolveFromPaths(SudoMechanism sudo, string password, params string[] paths)
{
var isWindows = IsWindows();
if (null == paths || 0 == paths.Length)
{
var complete = new List<string>();
var toolboxpath = Environment.GetEnvironmentVariable("DOCKER_TOOLBOX_INSTALL_PATH");
var envpaths = Environment.GetEnvironmentVariable("PATH")?.Split(isWindows ? ';' : ':');
if (null != envpaths)
complete.AddRange(envpaths);
if (null != toolboxpath)
complete.Add(toolboxpath);
paths = complete.ToArray();
}
if (null == paths)
return new DockerBinary[0];
var list = new List<DockerBinary>();
foreach (var path in paths)
{
try
{
if (!Directory.Exists(path))
{
continue;
}
if (isWindows)
{
list.AddRange(from file in Directory.GetFiles(path, "docker*.*")
let f = Path.GetFileName(file.ToLower())
where null != f && (f.Equals("docker.exe") || f.Equals("docker-compose.exe") ||
f.Equals("docker-machine.exe"))
select new DockerBinary(path, f, sudo, password));
var dockercli = Path.GetFullPath(Path.Combine(path, "..\\.."));
if (File.Exists(Path.Combine(dockercli, "dockercli.exe")))
{
list.Add(new DockerBinary(dockercli, "dockercli.exe", sudo, password));
}
continue;
}
list.AddRange(from file in Directory.GetFiles(path, "docker*")
let f = Path.GetFileName(file)
let f2 = f.ToLower()
where f2.Equals("docker") || f2.Equals("docker-compose") || f2.Equals("docker-machine")
select new DockerBinary(path, f, sudo, password));
}
catch (Exception e)
{
// Illegal character in path if env variable PATH like this (spaces before ';'):
// c:\folder1;c:\folder2;c:\folder3 ;
Logger.Log("Failed to get docker binary from path: " + path + Environment.NewLine + e);
}
}
return list;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions