diff --git a/src/argv.ts b/src/argv.ts index 842fe3cbc..e697dac21 100644 --- a/src/argv.ts +++ b/src/argv.ts @@ -215,10 +215,9 @@ export class Argv { return this.map.get("privileged") ?? false; } - get device (): string | null { - const device = this.map.get("device"); - if (!device) return null; - return device; + get device (): string[] { + const val = this.map.get("device") ?? []; + return typeof val == "string" ? val.split(" ") : val; } get ulimit (): string | null { diff --git a/src/index.ts b/src/index.ts index 2e20702dd..cb8ef1af5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -218,8 +218,8 @@ process.on("SIGUSR2", async () => await cleanupJobResources(jobs)); requiresArg: false, }) .option("device", { - type: "string", - description: "Set docker executor device option", + type: "array", + description: "Add devices to docker executor", requiresArg: false, }) .option("ulimit", { diff --git a/src/job.ts b/src/job.ts index 008b8ad1c..cbd8fa148 100644 --- a/src/job.ts +++ b/src/job.ts @@ -837,8 +837,8 @@ export class Job { dockerCmd += "--privileged "; } - if (this.argv.device) { - dockerCmd += `--device=${this.argv.device} `; + for (const device of this.argv.device) { + dockerCmd += `--device ${device} `; } if (this.argv.ulimit !== null) { @@ -1418,8 +1418,8 @@ export class Job { dockerCmd += "--privileged "; } - if (this.argv.device) { - dockerCmd += `--device=${this.argv.device} `; + for (const device of this.argv.device) { + dockerCmd += `--device ${device} `; } if (this.argv.ulimit !== null) {