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

Try to auto-detect docker or podman binary #1017

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as fs from "fs-extra";
import * as dotenv from "dotenv";
import * as path from "path";
import camelCase from "camelcase";
import execa from "execa";

export class Argv {

Expand Down Expand Up @@ -192,6 +193,20 @@ export class Argv {
}

get containerExecutable (): string {
return this.map.get("containerExecutable") ?? "docker";
if (!this.map.get("containerExecutable")) {
for (const bin of ["docker", "podman"]) {
try {
execa.sync(bin, ["version"]);
this.map.set("containerExecutable", bin);
break;
} catch {
continue;
}
}
if (!this.map.get("containerExecutable")) {
throw Object.assign(new Error("container executable not found"), {code: "ENOENT"});
}
}
return this.map.get("containerExecutable");
}
}