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

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

Open
georgearnall opened this issue Aug 20, 2024 · 1 comment
Open

Comments

@georgearnall
Copy link

georgearnall commented Aug 20, 2024

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;
}

@hwoodiwiss
Copy link

hwoodiwiss commented Nov 27, 2024

Is it worth considering how the .NET SDK supports this for containerization?
https://github.com/dotnet/sdk/blob/main/src/Containers/Microsoft.NET.Build.Containers/LocalDaemons/DockerCli.cs#L342-L376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants