UNPKG

@apiclient.xyz/docker

Version:

Provides easy communication with Docker remote API from Node.js, with TypeScript support.

148 lines (147 loc) 4.58 kB
import * as plugins from './plugins.js'; import * as interfaces from './interfaces/index.js'; import { DockerHost } from './classes.host.js'; import { DockerResource } from './classes.base.js'; export declare class DockerContainer extends DockerResource { /** * Internal: Get all containers * Public API: Use dockerHost.listContainers() instead */ static _list(dockerHostArg: DockerHost): Promise<DockerContainer[]>; /** * Internal: Get a container by ID * Public API: Use dockerHost.getContainerById(id) instead * Returns undefined if container does not exist */ static _fromId(dockerHostArg: DockerHost, containerId: string): Promise<DockerContainer | undefined>; /** * Internal: Create a container * Public API: Use dockerHost.createContainer(descriptor) instead */ static _create(dockerHost: DockerHost, containerCreationDescriptor: interfaces.IContainerCreationDescriptor): Promise<DockerContainer>; Id: string; Names: string[]; Image: string; ImageID: string; Command: string; Created: number; Ports: interfaces.TPorts; Labels: interfaces.TLabels; State: string; Status: string; HostConfig: any; NetworkSettings: { Networks: { [key: string]: { IPAMConfig: any; Links: any; Aliases: any; NetworkID: string; EndpointID: string; Gateway: string; IPAddress: string; IPPrefixLen: number; IPv6Gateway: string; GlobalIPv6Address: string; GlobalIPv6PrefixLen: number; MacAddress: string; DriverOpts: any; }; }; }; Mounts: any; constructor(dockerHostArg: DockerHost, dockerContainerObjectArg: any); /** * Refreshes this container's state from the Docker daemon */ refresh(): Promise<void>; /** * Inspects the container and returns detailed information */ inspect(): Promise<any>; /** * Starts the container */ start(): Promise<void>; /** * Stops the container * @param options Options for stopping (e.g., timeout in seconds) */ stop(options?: { t?: number; }): Promise<void>; /** * Removes the container * @param options Options for removal (force, remove volumes, remove link) */ remove(options?: { force?: boolean; v?: boolean; link?: boolean; }): Promise<void>; /** * Gets container logs * @param options Log options (stdout, stderr, timestamps, tail, since, follow) */ logs(options?: { stdout?: boolean; stderr?: boolean; timestamps?: boolean; tail?: number | 'all'; since?: number; follow?: boolean; }): Promise<string>; /** * Gets container stats * @param options Stats options (stream for continuous stats) */ stats(options?: { stream?: boolean; }): Promise<any>; /** * Streams container logs continuously (follow mode) * Returns a readable stream that emits log data as it's produced * @param options Log streaming options */ streamLogs(options?: { stdout?: boolean; stderr?: boolean; timestamps?: boolean; tail?: number | 'all'; since?: number; }): Promise<plugins.smartstream.stream.Readable>; /** * Attaches to the container's main process (PID 1) * Returns a duplex stream for bidirectional communication * @param options Attach options */ attach(options?: { stream?: boolean; stdin?: boolean; stdout?: boolean; stderr?: boolean; logs?: boolean; }): Promise<{ stream: plugins.smartstream.stream.Duplex; close: () => Promise<void>; }>; /** * Executes a command in the container * Returns a duplex stream for command interaction * @param command Command to execute (string or array of strings) * @param options Exec options */ exec(command: string | string[], options?: { tty?: boolean; attachStdin?: boolean; attachStdout?: boolean; attachStderr?: boolean; env?: string[]; workingDir?: string; user?: string; }): Promise<{ stream: plugins.smartstream.stream.Duplex; close: () => Promise<void>; inspect: () => Promise<interfaces.IExecInspectInfo>; }>; }