import type * as plugins from '../plugins.js'; import type { TLabels } from './label.js'; export type TContainerProtocol = 'tcp' | 'udp' | 'sctp'; export type TLoopbackHostIp = '127.0.0.1' | '::1'; export type TContainerCommand = [string, ...string[]]; export type TDockerHealthcheckTest = ['NONE'] | ['CMD', string, ...string[]] | ['CMD-SHELL', string]; export interface IContainerBindMount { source: string; target: string; readOnly?: boolean; /** Ask Docker to create a missing bind source on the host. Defaults to false. */ createMountpoint?: boolean; } export interface IContainerNamedVolumeMount { /** Exact Docker named-volume name, such as one returned by createVolume(). */ source: string; target: string; readOnly?: boolean; } export interface IContainerTmpfsMount { target: string; sizeBytes?: number; mode?: number; } export interface IContainerNetworkEndpoint { /** Complete immutable Docker network ID: local 64-hex or Swarm 25-base36. */ networkId: string; aliases?: string[]; } export interface IContainerPortBinding { containerPort: number; hostPort?: number; protocol?: TContainerProtocol; /** Standalone lifecycle ports may only be published on loopback. */ hostIp: TLoopbackHostIp; } export interface IContainerHealthcheck { test: TDockerHealthcheckTest; intervalMs?: number; timeoutMs?: number; startPeriodMs?: number; startIntervalMs?: number; retries?: number; } /** * Exact standalone-container creation contract. * * `imageId` must be the immutable local ID returned by `DockerHost.pullImage()` * or `DockerHost.getImageById()`. Registry references are evidence only and are * never used for Docker's mutable image lookup during container creation. */ export interface IContainerCreationDescriptor { name: string; imageId: string; imageReference?: string; /** Explicit non-root user name, uid, or uid:gid. */ user: string; /** Permit an explicit root user only after the daemon proves rootless mode. */ allowRootOnRootless?: true; /** Executable and arguments. Shell strings are intentionally unsupported. */ command: TContainerCommand; entrypoint?: TContainerCommand; workingDirectory?: string; tty?: boolean; openStdin?: boolean; stdinOnce?: boolean; init?: boolean; stopSignal?: string; stopTimeout?: number; hostname?: string; memoryBytes?: number; /** Docker's combined memory plus swap limit, in bytes. */ memorySwapBytes?: number; nanoCpus?: number; pidsLimit?: number; shmSize?: number; logDriver?: 'none'; env?: Record; labels?: TLabels; bindMounts?: IContainerBindMount[]; namedVolumeMounts?: IContainerNamedVolumeMount[]; tmpfsMounts?: IContainerTmpfsMount[]; readOnlyRootFilesystem?: boolean; /** Creates a fully isolated container without a Docker network. */ networkMode?: 'none'; networkEndpoints?: IContainerNetworkEndpoint[]; portBindings?: IContainerPortBinding[]; healthcheck?: IContainerHealthcheck; } export interface IContainerListOptions { /** Includes stopped containers. Defaults to true. */ all?: boolean; filters?: Record; } export interface IContainerStopOptions { timeoutSeconds?: number; signal?: string; } export interface IContainerRemoveOptions { force?: boolean; removeAnonymousVolumes?: boolean; } export interface IContainerLogsOptions { stdout?: boolean; stderr?: boolean; timestamps?: boolean; tail?: number | 'all'; since?: number; } export interface IContainerStatsOptions { stream?: boolean; oneShot?: boolean; } export interface IContainerReadOptions { /** Request deadline in milliseconds. Defaults to 30000; pass 0 to disable. */ timeoutMs?: number; /** Cancels the pending exact-container request. */ signal?: AbortSignal; } /** Validated from the exact-ID container inspection. */ export interface IContainerRuntimeState { Status: 'created' | 'running' | 'paused' | 'restarting' | 'removing' | 'exited' | 'dead'; Running: boolean; OOMKilled: boolean; Pid: number; ExitCode: number; } /** A physical container run, identified by Docker's exact RFC3339Nano start time. */ export interface IContainerRunState extends IContainerRuntimeState { StartedAt: string; /** Canonical decimal Unix nanoseconds; safe to compare with an event's timeNanoExact. */ startedAtUnixNano: string; } export type TContainerWaitCondition = 'not-running' | 'next-exit' | 'removed'; export interface IContainerWaitResult { exitCode: number; errorMessage?: string; } export interface IContainerStreamLogsOptions extends IContainerLogsOptions { demux?: boolean; } export interface IContainerAttachOptions extends IContainerReadOptions { /** Hijacked attach handshake deadline. Defaults to 30000; pass 0 to disable. */ timeoutMs?: number; /** Cancels a pending handshake and closes an active attachment. */ signal?: AbortSignal; stream?: boolean; stdin?: boolean; stdout?: boolean; stderr?: boolean; logs?: boolean; detachKeys?: string; } export type TContainerStartStatus = 'started' | 'already-running'; export type TContainerStopStatus = 'stopped' | 'already-stopped'; export type TContainerRemoveStatus = 'removed' | 'already-removed'; export interface IContainerInteractiveExecOptions { env?: Record; workingDirectory?: string; user?: string; /** Allocates a TTY. Defaults to true. */ tty?: boolean; detachKeys?: string; /** Initial TTY dimensions as [height, width]. */ consoleSize?: [number, number]; /** Handshake deadline. Defaults to 30 seconds. */ timeoutMs?: number; /** Cancels the pending hijack handshake and closes an active session on abort. */ signal?: AbortSignal; } export interface IContainerInteractiveExec { execId: string; stream: plugins.stream.Duplex; close: () => Promise; inspect: () => Promise; } export interface IContainerExecOptions { env?: Record; workingDirectory?: string; user?: string; /** Whole-operation deadline. Defaults to 30 seconds. */ timeoutMs?: number; /** Maximum stdout and stderr payload bytes combined. Defaults to 1 MiB. */ maxOutputBytes?: number; } export interface IContainerExecResult { execId: string; stdout: string; stderr: string; exitCode: number; inspect: IExecInspectInfo; } /** * Information about an exec instance after it has finished. */ export interface IExecInspectInfo { ExitCode: number; Running: boolean; Pid: number; ContainerID: string; ID: string; OpenStderr: boolean; OpenStdin: boolean; OpenStdout: boolean; CanRemove: boolean; DetachKeys: string; ProcessConfig: { tty: boolean; entrypoint: string; arguments: string[]; privileged: boolean; user?: string; }; }