add docker support and udp proto in redirs
This commit is contained in:
parent
6a77e1294e
commit
39d75031ba
5 changed files with 35 additions and 9 deletions
|
@ -7,8 +7,9 @@ const log = log_from("nspawn");
|
|||
export function container_command(name: string, directory: string, opts?: {
|
||||
veth?: boolean;
|
||||
boot?: boolean;
|
||||
ports?: [number, number][];
|
||||
ports?: ([number, number] | [number, number, "tcp" | "udp"])[];
|
||||
cmd_opts?: Deno.CommandOptions;
|
||||
syscall_filter?: string[];
|
||||
}) {
|
||||
const args = [
|
||||
`--machine=${name}`,
|
||||
|
@ -16,7 +17,10 @@ export function container_command(name: string, directory: string, opts?: {
|
|||
];
|
||||
if (opts?.veth ?? false) args.push("--network-veth");
|
||||
if (opts?.boot ?? false) args.push("--boot");
|
||||
for (const [from, to] of opts?.ports ?? []) args.push(`--port=${from}:${to}`);
|
||||
for (const [from, to, proto] of opts?.ports ?? []) {
|
||||
args.push(proto === undefined ? `--port=${from}:${to}` : `--port=${proto}:${from}:${to}`);
|
||||
}
|
||||
for (const call of opts?.syscall_filter ?? []) args.push(`--system-call-filter=${call}`);
|
||||
const command = new Deno.Command("systemd-nspawn", { ...opts?.cmd_opts, args });
|
||||
return command;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue