@zukhruf/docker 0.0.0-stage → 0.3.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +902 -2
- package/dist/api-version.d.ts +7 -0
- package/dist/api-version.d.ts.map +1 -0
- package/dist/api-version.js +22 -0
- package/dist/api-version.js.map +1 -0
- package/dist/container-process.d.ts +35 -0
- package/dist/container-process.d.ts.map +1 -0
- package/dist/container-process.js +91 -0
- package/dist/container-process.js.map +1 -0
- package/dist/containers.d.ts +160 -0
- package/dist/containers.d.ts.map +1 -0
- package/dist/containers.js +700 -0
- package/dist/containers.js.map +1 -0
- package/dist/context-store.d.ts +22 -0
- package/dist/context-store.d.ts.map +1 -0
- package/dist/context-store.js +128 -0
- package/dist/context-store.js.map +1 -0
- package/dist/docker.d.ts +57 -0
- package/dist/docker.d.ts.map +1 -0
- package/dist/docker.js +96 -0
- package/dist/docker.js.map +1 -0
- package/dist/engine-api.d.ts +390 -0
- package/dist/engine-api.d.ts.map +1 -0
- package/dist/engine-api.js +4 -0
- package/dist/engine-api.js.map +1 -0
- package/dist/engine-client.d.ts +74 -0
- package/dist/engine-client.d.ts.map +1 -0
- package/dist/engine-client.js +253 -0
- package/dist/engine-client.js.map +1 -0
- package/dist/errors.d.ts +133 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +214 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +13 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +22 -0
- package/dist/host.js.map +1 -0
- package/dist/images.d.ts +40 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +173 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/multiplexed-stream.d.ts +11 -0
- package/dist/multiplexed-stream.d.ts.map +1 -0
- package/dist/multiplexed-stream.js +81 -0
- package/dist/multiplexed-stream.js.map +1 -0
- package/dist/ndjson.d.ts +7 -0
- package/dist/ndjson.d.ts.map +1 -0
- package/dist/ndjson.js +21 -0
- package/dist/ndjson.js.map +1 -0
- package/dist/networks.d.ts +46 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +170 -0
- package/dist/networks.js.map +1 -0
- package/dist/options.d.ts +7 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +2 -0
- package/dist/options.js.map +1 -0
- package/dist/output.d.ts +18 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +21 -0
- package/dist/output.js.map +1 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +20 -0
- package/dist/progress.js.map +1 -0
- package/dist/ssh-connection.d.ts +23 -0
- package/dist/ssh-connection.d.ts.map +1 -0
- package/dist/ssh-connection.js +225 -0
- package/dist/ssh-connection.js.map +1 -0
- package/dist/tar-reader.d.ts +22 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +163 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/tar-writer.d.ts +16 -0
- package/dist/tar-writer.d.ts.map +1 -0
- package/dist/tar-writer.js +114 -0
- package/dist/tar-writer.js.map +1 -0
- package/dist/transport.d.ts +29 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +56 -0
- package/dist/transport.js.map +1 -0
- package/dist/volumes.d.ts +41 -0
- package/dist/volumes.d.ts.map +1 -0
- package/dist/volumes.js +119 -0
- package/dist/volumes.js.map +1 -0
- package/package.json +43 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** From 1.44 on, a create of a network with a taken name fails, and networks.createOrGet() needs that. */
|
|
2
|
+
export declare const LOWEST_API_VERSION = "1.44";
|
|
3
|
+
/** The highest API version that the tests of the package run on. */
|
|
4
|
+
export declare const HIGHEST_API_VERSION = "1.56";
|
|
5
|
+
/** The lower of the engine's highest version and the package's highest version. */
|
|
6
|
+
export declare function negotiateApiVersion(host: string, engineVersion: string): string;
|
|
7
|
+
//# sourceMappingURL=api-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-version.d.ts","sourceRoot":"","sources":["../src/api-version.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,eAAO,MAAM,kBAAkB,SAAS,CAAC;AACzC,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAS1C,mFAAmF;AACnF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GACpB,MAAM,CAUR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UnsupportedEngineError } from "./errors.js";
|
|
2
|
+
/** From 1.44 on, a create of a network with a taken name fails, and networks.createOrGet() needs that. */
|
|
3
|
+
export const LOWEST_API_VERSION = '1.44';
|
|
4
|
+
/** The highest API version that the tests of the package run on. */
|
|
5
|
+
export const HIGHEST_API_VERSION = '1.56';
|
|
6
|
+
/** Compares the numbers of two versions, so that 1.9 is lower than 1.10. */
|
|
7
|
+
function compareApiVersions(left, right) {
|
|
8
|
+
const [leftMajor = 0, leftMinor = 0] = left.split('.').map(Number);
|
|
9
|
+
const [rightMajor = 0, rightMinor = 0] = right.split('.').map(Number);
|
|
10
|
+
return leftMajor - rightMajor || leftMinor - rightMinor;
|
|
11
|
+
}
|
|
12
|
+
/** The lower of the engine's highest version and the package's highest version. */
|
|
13
|
+
export function negotiateApiVersion(host, engineVersion) {
|
|
14
|
+
if (!/^\d+\.\d+$/.test(engineVersion) ||
|
|
15
|
+
compareApiVersions(engineVersion, LOWEST_API_VERSION) < 0) {
|
|
16
|
+
throw new UnsupportedEngineError(host, engineVersion, LOWEST_API_VERSION);
|
|
17
|
+
}
|
|
18
|
+
return compareApiVersions(engineVersion, HIGHEST_API_VERSION) < 0
|
|
19
|
+
? engineVersion
|
|
20
|
+
: HIGHEST_API_VERSION;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=api-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-version.js","sourceRoot":"","sources":["../src/api-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAE1C,4EAA4E;AAC5E,SAAS,kBAAkB,CAAC,IAAY,EAAE,KAAa;IACrD,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,CAAC,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtE,OAAO,SAAS,GAAG,UAAU,IAAI,SAAS,GAAG,UAAU,CAAC;AAC1D,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,aAAqB;IAErB,IACE,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC;QACjC,kBAAkB,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACzD,CAAC;QACD,MAAM,IAAI,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,kBAAkB,CAAC,aAAa,EAAE,mBAAmB,CAAC,GAAG,CAAC;QAC/D,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,mBAAmB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HijackedConnection } from './engine-client.ts';
|
|
2
|
+
import { type OutputChunk } from './multiplexed-stream.ts';
|
|
3
|
+
import { type ExecResult } from './output.ts';
|
|
4
|
+
export interface ContainerProcessOptions {
|
|
5
|
+
/** Gives the process a writable `stdin`. */
|
|
6
|
+
stdin: boolean;
|
|
7
|
+
/** An abort rejects the iteration with the reason of the signal. It does not stop the command. */
|
|
8
|
+
signal?: AbortSignal | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Gives the exit code. `outputEnded` resolves when the output ends, and
|
|
11
|
+
* rejects when the iteration ends first.
|
|
12
|
+
*/
|
|
13
|
+
exitCode: (outputEnded: Promise<void>) => Promise<number>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* An exec or an attached container: one stream of output chunks in the order
|
|
17
|
+
* of the engine, given once, a writable `stdin` when it has one, and the exit
|
|
18
|
+
* code when it ends.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ContainerProcess implements AsyncIterable<OutputChunk> {
|
|
21
|
+
#private;
|
|
22
|
+
/** Present with { stdin: true }. Only close() ends the input; an empty write is dropped. */
|
|
23
|
+
readonly stdin: WritableStream<Uint8Array> | undefined;
|
|
24
|
+
constructor(connection: HijackedConnection, options: ContainerProcessOptions);
|
|
25
|
+
/**
|
|
26
|
+
* The exit code. For an exec, it comes after the output ends. It rejects
|
|
27
|
+
* when the iteration ends before the output ends.
|
|
28
|
+
*/
|
|
29
|
+
get exitCode(): Promise<number>;
|
|
30
|
+
/** The chunks, once. A second iteration rejects. */
|
|
31
|
+
[Symbol.asyncIterator](): AsyncIterator<OutputChunk>;
|
|
32
|
+
/** Reads each chunk and gives the result. */
|
|
33
|
+
collect(): Promise<ExecResult>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=container-process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-process.d.ts","sourceRoot":"","sources":["../src/container-process.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,uBAAuB;IACtC,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,kGAAkG;IAClG,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,QAAQ,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D;AAmBD;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,aAAa,CAAC,WAAW,CAAC;;IACjE,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC;gBAMrD,UAAU,EAAE,kBAAkB,EAC9B,OAAO,EAAE,uBAAuB;IA6ClC;;;OAGG;IACH,IAAI,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAE9B;IAED,oDAAoD;IACpD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,WAAW,CAAC;IASpD,6CAA6C;IACvC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;CAIrC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DockerError } from "./errors.js";
|
|
2
|
+
import { outputChunks } from "./multiplexed-stream.js";
|
|
3
|
+
import { readOutput } from "./output.js";
|
|
4
|
+
async function* withHead(head, socket) {
|
|
5
|
+
if (head.byteLength > 0)
|
|
6
|
+
yield head;
|
|
7
|
+
for await (const chunk of socket) {
|
|
8
|
+
if (chunk instanceof Uint8Array)
|
|
9
|
+
yield chunk;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Writes to the socket and resolves when the socket took the bytes. */
|
|
13
|
+
async function write(socket, chunk) {
|
|
14
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
15
|
+
socket.write(chunk, (error) => (error ? reject(error) : resolve()));
|
|
16
|
+
return promise;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* An exec or an attached container: one stream of output chunks in the order
|
|
20
|
+
* of the engine, given once, a writable `stdin` when it has one, and the exit
|
|
21
|
+
* code when it ends.
|
|
22
|
+
*/
|
|
23
|
+
export class ContainerProcess {
|
|
24
|
+
/** Present with { stdin: true }. Only close() ends the input; an empty write is dropped. */
|
|
25
|
+
stdin;
|
|
26
|
+
/** Holds the chunks until the first iteration takes them. */
|
|
27
|
+
#unread;
|
|
28
|
+
#exitCode;
|
|
29
|
+
constructor(connection, options) {
|
|
30
|
+
const { socket, head, contentType } = connection;
|
|
31
|
+
const { signal } = options;
|
|
32
|
+
// An error before the first read waits for the iteration, which rejects with it.
|
|
33
|
+
socket.on('error', () => undefined);
|
|
34
|
+
const abort = () => socket.destroy(signal?.reason);
|
|
35
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
36
|
+
socket.once('close', () => signal?.removeEventListener('abort', abort));
|
|
37
|
+
const outputEnded = Promise.withResolvers();
|
|
38
|
+
outputEnded.promise.catch(() => undefined);
|
|
39
|
+
async function* read() {
|
|
40
|
+
try {
|
|
41
|
+
signal?.throwIfAborted();
|
|
42
|
+
yield* outputChunks(withHead(head, socket), contentType);
|
|
43
|
+
outputEnded.resolve();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
outputEnded.reject(error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
outputEnded.reject(new DockerError('The iteration ended before the output ended.'));
|
|
51
|
+
socket.destroy();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this.#unread = [read()];
|
|
55
|
+
const exitCode = options.exitCode(outputEnded.promise);
|
|
56
|
+
// A caller that never reads the exit code gets no unhandled rejection.
|
|
57
|
+
exitCode.catch(() => undefined);
|
|
58
|
+
this.#exitCode = () => exitCode;
|
|
59
|
+
this.stdin = options.stdin
|
|
60
|
+
? new WritableStream({
|
|
61
|
+
write: async (chunk) => {
|
|
62
|
+
if (chunk.byteLength > 0)
|
|
63
|
+
await write(socket, chunk);
|
|
64
|
+
},
|
|
65
|
+
close: () => connection.endInput(),
|
|
66
|
+
abort: () => connection.endInput(),
|
|
67
|
+
})
|
|
68
|
+
: undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The exit code. For an exec, it comes after the output ends. It rejects
|
|
72
|
+
* when the iteration ends before the output ends.
|
|
73
|
+
*/
|
|
74
|
+
get exitCode() {
|
|
75
|
+
return this.#exitCode();
|
|
76
|
+
}
|
|
77
|
+
/** The chunks, once. A second iteration rejects. */
|
|
78
|
+
[Symbol.asyncIterator]() {
|
|
79
|
+
const chunks = this.#unread.pop();
|
|
80
|
+
if (chunks !== undefined)
|
|
81
|
+
return chunks;
|
|
82
|
+
const error = new DockerError('A container process gives its output once, and an iteration already read it.');
|
|
83
|
+
return { next: async () => Promise.reject(error) };
|
|
84
|
+
}
|
|
85
|
+
/** Reads each chunk and gives the result. */
|
|
86
|
+
async collect() {
|
|
87
|
+
const output = await readOutput(this);
|
|
88
|
+
return { exitCode: await this.exitCode, ...output };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=container-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-process.js","sourceRoot":"","sources":["../src/container-process.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAoB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAmB,UAAU,EAAE,MAAM,aAAa,CAAC;AAc1D,KAAK,SAAS,CAAC,CAAC,QAAQ,CACtB,IAAY,EACZ,MAAc;IAEd,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC;QAAE,MAAM,IAAI,CAAC;IACpC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,M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AC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,oDAAoD;IACpD,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,8EAA8E,CAC/E,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,CAAC;IAED,6CAA6C;IAC7C,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ContainerProcess } from './container-process.ts';
|
|
2
|
+
import type * as EngineApi from './engine-api.ts';
|
|
3
|
+
import { type EngineClient } from './engine-client.ts';
|
|
4
|
+
import type { Images } from './images.ts';
|
|
5
|
+
import { type OutputChunk } from './multiplexed-stream.ts';
|
|
6
|
+
import type { CancelOptions, Filters } from './options.ts';
|
|
7
|
+
import { type ExecResult, type Output } from './output.ts';
|
|
8
|
+
/** A file or a directory for writeFiles(). It belongs to uid:gid, or to 0:0. */
|
|
9
|
+
export type ContainerFile = {
|
|
10
|
+
path: string;
|
|
11
|
+
data: string | Uint8Array;
|
|
12
|
+
mode?: number;
|
|
13
|
+
uid?: number;
|
|
14
|
+
gid?: number;
|
|
15
|
+
} | {
|
|
16
|
+
path: string;
|
|
17
|
+
directory: true;
|
|
18
|
+
mode?: number;
|
|
19
|
+
uid?: number;
|
|
20
|
+
gid?: number;
|
|
21
|
+
};
|
|
22
|
+
/** The query of the logs, as the Engine API takes it. */
|
|
23
|
+
export interface LogQuery {
|
|
24
|
+
tail?: number | 'all';
|
|
25
|
+
/** Seconds since the Unix epoch. */
|
|
26
|
+
since?: number;
|
|
27
|
+
timestamps?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** The result of createOrGet(): an owned handle when this call created the resource. */
|
|
30
|
+
export type Created<Key extends string, Owned, Found> = ({
|
|
31
|
+
created: true;
|
|
32
|
+
} & Record<Key, Owned>) | ({
|
|
33
|
+
created: false;
|
|
34
|
+
} & Record<Key, Found>);
|
|
35
|
+
/** A container, by the ID that the engine gave it. It has no disposal. */
|
|
36
|
+
export declare class Container {
|
|
37
|
+
#private;
|
|
38
|
+
readonly id: string;
|
|
39
|
+
constructor(client: EngineClient, id: string);
|
|
40
|
+
inspect(options?: CancelOptions): Promise<EngineApi.ContainerInspectResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolves for 304 (already running). A 404 is a missing container or a
|
|
43
|
+
* missing network: an inspect of the container tells which, and a lookup of
|
|
44
|
+
* each of its networks names the missing one. An engine in swarm mode
|
|
45
|
+
* answers a missing network with 500 ("Could not attach to network", probed
|
|
46
|
+
* at API 1.51), so a 500 gets the same lookup.
|
|
47
|
+
*/
|
|
48
|
+
start(options?: CancelOptions): Promise<void>;
|
|
49
|
+
/** Resolves for 304 (already stopped). t: seconds before the engine kills the main process. */
|
|
50
|
+
stop(options?: CancelOptions & {
|
|
51
|
+
t?: number;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
restart(options?: CancelOptions & {
|
|
54
|
+
t?: number;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
/** A 409 means that the container does not run: an inspect gives its state. */
|
|
57
|
+
kill(processSignal?: string, options?: CancelOptions): Promise<void>;
|
|
58
|
+
pause(options?: CancelOptions): Promise<void>;
|
|
59
|
+
unpause(options?: CancelOptions): Promise<void>;
|
|
60
|
+
wait(options?: CancelOptions & {
|
|
61
|
+
condition?: 'not-running' | 'next-exit' | 'removed';
|
|
62
|
+
}): Promise<EngineApi.ContainerWaitResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves for 404. A 409 is a removal that is already in progress, or,
|
|
65
|
+
* without `force`, a container that runs: an inspect tells which. For a
|
|
66
|
+
* removal in progress, it inspects the container until it is gone, and
|
|
67
|
+
* when the other removal ends and leaves the container, it sends a forced
|
|
68
|
+
* removal again. A container
|
|
69
|
+
* that runs or is paused rejects with ContainerRunningError. The engine
|
|
70
|
+
* gives the state 'running' while it kills the container for a forced
|
|
71
|
+
* removal, so with `force` the state alone does not tell: it waits.
|
|
72
|
+
*/
|
|
73
|
+
remove(options?: CancelOptions & {
|
|
74
|
+
force?: boolean;
|
|
75
|
+
v?: boolean;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
/** The published binding of a port of the container; undefined when it is not published. The IPv4 binding comes first. */
|
|
78
|
+
port(containerPort: number, protocol?: 'tcp' | 'udp', options?: CancelOptions): Promise<{
|
|
79
|
+
host: string;
|
|
80
|
+
port: number;
|
|
81
|
+
} | undefined>;
|
|
82
|
+
/** The logs until now. */
|
|
83
|
+
logs(options?: CancelOptions & LogQuery): Promise<Output>;
|
|
84
|
+
/** The logs as the container writes them. The iteration ends when the container stops. */
|
|
85
|
+
followLogs(options?: CancelOptions & LogQuery): AsyncIterable<OutputChunk>;
|
|
86
|
+
/** Runs a command in the container and reads its output to the end. stdin is sent, and then the input ends. */
|
|
87
|
+
exec(body: EngineApi.ExecConfig, options?: CancelOptions & {
|
|
88
|
+
stdin?: string | Uint8Array;
|
|
89
|
+
}): Promise<ExecResult>;
|
|
90
|
+
/** Runs a command in the container and gives its container process while it runs. */
|
|
91
|
+
spawn(body: EngineApi.ExecConfig, options?: CancelOptions & {
|
|
92
|
+
stdin?: boolean;
|
|
93
|
+
}): Promise<ContainerProcess>;
|
|
94
|
+
/**
|
|
95
|
+
* Attaches to the output of the container. For a created container, the
|
|
96
|
+
* exit code is the code of its next exit, so attach before start(). For a
|
|
97
|
+
* running container, it is the code when the container stops. An exited or
|
|
98
|
+
* a paused container rejects with ContainerNotRunningError: Moby gives no
|
|
99
|
+
* 409 for an attach to an exited container, so the state of an inspect
|
|
100
|
+
* decides.
|
|
101
|
+
*/
|
|
102
|
+
attach(options?: CancelOptions & {
|
|
103
|
+
stdin?: boolean;
|
|
104
|
+
}): Promise<ContainerProcess>;
|
|
105
|
+
/** The path stat of a path in the container: HEAD of the archive. undefined for 404 when the container exists. */
|
|
106
|
+
stat(path: string, options?: CancelOptions): Promise<EngineApi.ContainerPathStat | undefined>;
|
|
107
|
+
/** The bytes of one regular file. A directory, a link and each other kind of entry reject with NotAFileError. */
|
|
108
|
+
readFile(path: string, options?: CancelOptions): Promise<Uint8Array>;
|
|
109
|
+
/**
|
|
110
|
+
* Sends one archive of the files. It extracts the archive in the deepest
|
|
111
|
+
* directory that holds each entry and that exists, which stat() finds. The
|
|
112
|
+
* engine creates each parent directory that an entry implies below it.
|
|
113
|
+
*/
|
|
114
|
+
writeFiles(files: ContainerFile[], options?: CancelOptions): Promise<void>;
|
|
115
|
+
/** The tar stream of a path in the container: a file, or a directory with its tree. */
|
|
116
|
+
getArchive(path: string, options?: CancelOptions): Promise<ReadableStream<Uint8Array>>;
|
|
117
|
+
/**
|
|
118
|
+
* Extracts a tar archive in a directory of the container. With copyUIDGID,
|
|
119
|
+
* each entry belongs to the user of the container (Config.User), not to
|
|
120
|
+
* the owner in the archive.
|
|
121
|
+
*/
|
|
122
|
+
putArchive(directory: string, archive: ReadableStream<Uint8Array> | Uint8Array, options?: CancelOptions & {
|
|
123
|
+
copyUIDGID?: boolean;
|
|
124
|
+
}): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
/** A container that this handle created. Disposal removes it with its anonymous volumes. */
|
|
127
|
+
export declare class OwnedContainer extends Container implements AsyncDisposable {
|
|
128
|
+
/** remove({ force: true, v: true }) */
|
|
129
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
/** The containers of one engine. */
|
|
132
|
+
export declare class Containers {
|
|
133
|
+
#private;
|
|
134
|
+
constructor(client: EngineClient, images: Images);
|
|
135
|
+
create(body: EngineApi.ContainerCreateRequest, options?: CancelOptions & {
|
|
136
|
+
name?: string;
|
|
137
|
+
platform?: string;
|
|
138
|
+
}): Promise<OwnedContainer>;
|
|
139
|
+
/**
|
|
140
|
+
* Creates the container, attaches to its output, starts it, waits for its
|
|
141
|
+
* end, and removes it. A non-zero exit code is data. A failure and a cancel
|
|
142
|
+
* also remove the container.
|
|
143
|
+
*/
|
|
144
|
+
run(body: EngineApi.ContainerCreateRequest, options?: CancelOptions & {
|
|
145
|
+
name?: string;
|
|
146
|
+
platform?: string;
|
|
147
|
+
}): Promise<ExecResult>;
|
|
148
|
+
/** Creates the container, or gives the one that has the name. The container that exists wins. */
|
|
149
|
+
createOrGet(body: EngineApi.ContainerCreateRequest, options: CancelOptions & {
|
|
150
|
+
name: string;
|
|
151
|
+
platform?: string;
|
|
152
|
+
}): Promise<Created<'container', OwnedContainer, Container>>;
|
|
153
|
+
/** One inspect: a handle with the ID of the engine, or undefined for 404. */
|
|
154
|
+
find(nameOrId: string, options?: CancelOptions): Promise<Container | undefined>;
|
|
155
|
+
list(options?: CancelOptions & {
|
|
156
|
+
all?: boolean;
|
|
157
|
+
filters?: Filters;
|
|
158
|
+
}): Promise<EngineApi.ContainerSummary[]>;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=containers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containers.d.ts","sourceRoot":"","sources":["../src/containers.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,oBAAoB,CAAC;AAe5B,OAAO,K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