@lakutata/docker 3.0.0-beta.0
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 +23 -0
- package/README.md +309 -0
- package/THIRD_PARTY_NOTICES.md +299 -0
- package/dist/cjs/client/BuildContext.d.ts +22 -0
- package/dist/cjs/client/BuildContext.js +76 -0
- package/dist/cjs/client/BuildKitProgress.d.ts +81 -0
- package/dist/cjs/client/BuildKitProgress.js +195 -0
- package/dist/cjs/client/DockerClient.d.ts +196 -0
- package/dist/cjs/client/DockerClient.js +312 -0
- package/dist/cjs/client/DockerConnection.d.ts +154 -0
- package/dist/cjs/client/DockerConnection.js +397 -0
- package/dist/cjs/client/DockerIgnore.d.ts +44 -0
- package/dist/cjs/client/DockerIgnore.js +186 -0
- package/dist/cjs/client/DockerRequestError.d.ts +17 -0
- package/dist/cjs/client/DockerRequestError.js +24 -0
- package/dist/cjs/client/DockerStreams.d.ts +35 -0
- package/dist/cjs/client/DockerStreams.js +117 -0
- package/dist/cjs/client/types/ContainerCreateResponse.d.ts +7 -0
- package/dist/cjs/client/types/ContainerCreateResponse.js +2 -0
- package/dist/cjs/client/types/ContainerStopQuery.d.ts +13 -0
- package/dist/cjs/client/types/ContainerStopQuery.js +2 -0
- package/dist/cjs/client/types/DeviceMapping.d.ts +8 -0
- package/dist/cjs/client/types/DeviceMapping.js +2 -0
- package/dist/cjs/client/types/IdResponse.d.ts +6 -0
- package/dist/cjs/client/types/IdResponse.js +2 -0
- package/dist/cjs/client/types/NetworkCreateResponse.d.ts +7 -0
- package/dist/cjs/client/types/NetworkCreateResponse.js +2 -0
- package/dist/cjs/client/types/PortBinding.d.ts +10 -0
- package/dist/cjs/client/types/PortBinding.js +2 -0
- package/dist/cjs/docker/ConnectionOptionsBuilder.d.ts +128 -0
- package/dist/cjs/docker/ConnectionOptionsBuilder.js +150 -0
- package/dist/cjs/docker/Docker.d.ts +301 -0
- package/dist/cjs/docker/Docker.js +703 -0
- package/dist/cjs/docker/exceptions/DockerConnectionException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerConnectionException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerContainerNotFoundException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageBuildException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImageBuildException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageImportException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImageImportException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
- package/dist/cjs/docker/exceptions/DockerImageNotFoundException.js +17 -0
- package/dist/cjs/docker/exceptions/DockerImagePullException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerImagePullException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerImagePushException.d.ts +8 -0
- package/dist/cjs/docker/exceptions/DockerImagePushException.js +15 -0
- package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
- package/dist/cjs/docker/exceptions/DockerImageRepoTagNotFoundException.js +15 -0
- package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
- package/dist/cjs/docker/exceptions/DockerNetworkNotFoundException.js +16 -0
- package/dist/cjs/docker/exceptions/DockerRequestException.d.ts +22 -0
- package/dist/cjs/docker/exceptions/DockerRequestException.js +24 -0
- package/dist/cjs/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
- package/dist/cjs/docker/interfaces/IDockerConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerHttpConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerHttpsConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerKeyObject.d.ts +14 -0
- package/dist/cjs/docker/interfaces/IDockerKeyObject.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
- package/dist/cjs/docker/interfaces/IDockerSSHConnectionOptions.js +2 -0
- package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
- package/dist/cjs/docker/interfaces/IDockerSocketConnectionOptions.js +2 -0
- package/dist/cjs/docker/lib/DockerContainer.d.ts +315 -0
- package/dist/cjs/docker/lib/DockerContainer.js +742 -0
- package/dist/cjs/docker/lib/DockerContainerTTY.d.ts +99 -0
- package/dist/cjs/docker/lib/DockerContainerTTY.js +157 -0
- package/dist/cjs/docker/lib/DockerImage.d.ts +153 -0
- package/dist/cjs/docker/lib/DockerImage.js +273 -0
- package/dist/cjs/docker/lib/EngineSettings.d.ts +41 -0
- package/dist/cjs/docker/lib/EngineSettings.js +86 -0
- package/dist/cjs/docker/lib/ParseBaseImages.d.ts +9 -0
- package/dist/cjs/docker/lib/ParseBaseImages.js +50 -0
- package/dist/cjs/docker/lib/ParseEnvToRecord.d.ts +14 -0
- package/dist/cjs/docker/lib/ParseEnvToRecord.js +25 -0
- package/dist/cjs/docker/lib/ParseRepositoryTag.d.ts +17 -0
- package/dist/cjs/docker/lib/ParseRepositoryTag.js +48 -0
- package/dist/cjs/docker/lib/RegistryAuth.d.ts +8 -0
- package/dist/cjs/docker/lib/RegistryAuth.js +15 -0
- package/dist/cjs/docker/options/DockerPruneOptions.d.ts +38 -0
- package/dist/cjs/docker/options/DockerPruneOptions.js +47 -0
- package/dist/cjs/docker/options/auth/DockerAuthOptions.d.ts +46 -0
- package/dist/cjs/docker/options/auth/DockerAuthOptions.js +59 -0
- package/dist/cjs/docker/options/container/ContainerCommitOptions.d.ts +28 -0
- package/dist/cjs/docker/options/container/ContainerCommitOptions.js +39 -0
- package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
- package/dist/cjs/docker/options/container/ContainerCreateTTYOptions.js +43 -0
- package/dist/cjs/docker/options/container/ContainerExecOptions.d.ts +26 -0
- package/dist/cjs/docker/options/container/ContainerExecOptions.js +38 -0
- package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
- package/dist/cjs/docker/options/container/ContainerExportDirectoryOptions.js +39 -0
- package/dist/cjs/docker/options/container/ContainerKillOptions.d.ts +25 -0
- package/dist/cjs/docker/options/container/ContainerKillOptions.js +36 -0
- package/dist/cjs/docker/options/container/ContainerLogsOptions.d.ts +48 -0
- package/dist/cjs/docker/options/container/ContainerLogsOptions.js +56 -0
- package/dist/cjs/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/cjs/docker/options/container/ContainerRemoveOptions.js +34 -0
- package/dist/cjs/docker/options/container/ContainerSettingOptions.d.ts +137 -0
- package/dist/cjs/docker/options/container/ContainerSettingOptions.js +136 -0
- package/dist/cjs/docker/options/container/ContainerStopOptions.d.ts +28 -0
- package/dist/cjs/docker/options/container/ContainerStopOptions.js +40 -0
- package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/cjs/docker/options/container/ContainerTTYConsoleSizeOptions.js +40 -0
- package/dist/cjs/docker/options/image/ImageBuildOptions.d.ts +117 -0
- package/dist/cjs/docker/options/image/ImageBuildOptions.js +111 -0
- package/dist/cjs/docker/options/image/ImageExportOptions.d.ts +33 -0
- package/dist/cjs/docker/options/image/ImageExportOptions.js +44 -0
- package/dist/cjs/docker/options/image/ImageImportOptions.d.ts +28 -0
- package/dist/cjs/docker/options/image/ImageImportOptions.js +42 -0
- package/dist/cjs/docker/options/image/ImagePullOptions.d.ts +49 -0
- package/dist/cjs/docker/options/image/ImagePullOptions.js +63 -0
- package/dist/cjs/docker/options/image/ImagePushOptions.d.ts +41 -0
- package/dist/cjs/docker/options/image/ImagePushOptions.js +56 -0
- package/dist/cjs/docker/options/image/ImageRemoveOptions.d.ts +26 -0
- package/dist/cjs/docker/options/image/ImageRemoveOptions.js +38 -0
- package/dist/cjs/docker/options/image/ImageTagOptions.d.ts +25 -0
- package/dist/cjs/docker/options/image/ImageTagOptions.js +38 -0
- package/dist/cjs/docker/options/network/NetworkCreateOptions.d.ts +54 -0
- package/dist/cjs/docker/options/network/NetworkCreateOptions.js +63 -0
- package/dist/cjs/docker/types/ContainerBind.d.ts +19 -0
- package/dist/cjs/docker/types/ContainerBind.js +2 -0
- package/dist/cjs/docker/types/ContainerCapability.d.ts +286 -0
- package/dist/cjs/docker/types/ContainerCapability.js +290 -0
- package/dist/cjs/docker/types/ContainerConfig.d.ts +67 -0
- package/dist/cjs/docker/types/ContainerConfig.js +2 -0
- package/dist/cjs/docker/types/ContainerDevice.d.ts +19 -0
- package/dist/cjs/docker/types/ContainerDevice.js +2 -0
- package/dist/cjs/docker/types/ContainerExecResult.d.ts +20 -0
- package/dist/cjs/docker/types/ContainerExecResult.js +2 -0
- package/dist/cjs/docker/types/ContainerNetwork.d.ts +46 -0
- package/dist/cjs/docker/types/ContainerNetwork.js +2 -0
- package/dist/cjs/docker/types/ContainerPort.d.ts +25 -0
- package/dist/cjs/docker/types/ContainerPort.js +2 -0
- package/dist/cjs/docker/types/ContainerRestartPolicy.d.ts +11 -0
- package/dist/cjs/docker/types/ContainerRestartPolicy.js +2 -0
- package/dist/cjs/docker/types/ContainerState.d.ts +48 -0
- package/dist/cjs/docker/types/ContainerState.js +2 -0
- package/dist/cjs/docker/types/ContainerStats.d.ts +408 -0
- package/dist/cjs/docker/types/ContainerStats.js +2 -0
- package/dist/cjs/docker/types/DockerOutputCallback.d.ts +8 -0
- package/dist/cjs/docker/types/DockerOutputCallback.js +2 -0
- package/dist/cjs/docker/types/ImageConfig.d.ts +34 -0
- package/dist/cjs/docker/types/ImageConfig.js +2 -0
- package/dist/cjs/docker/types/ImageExposePort.d.ts +17 -0
- package/dist/cjs/docker/types/ImageExposePort.js +2 -0
- package/dist/cjs/docker/types/NetworkInfo.d.ts +59 -0
- package/dist/cjs/docker/types/NetworkInfo.js +2 -0
- package/dist/cjs/docker/types/RepositoryTag.d.ts +15 -0
- package/dist/cjs/docker/types/RepositoryTag.js +2 -0
- package/dist/cjs/exports/Docker.d.ts +73 -0
- package/dist/cjs/exports/Docker.js +92 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/client/BuildContext.js +70 -0
- package/dist/esm/client/BuildKitProgress.js +190 -0
- package/dist/esm/client/DockerClient.js +307 -0
- package/dist/esm/client/DockerConnection.js +355 -0
- package/dist/esm/client/DockerIgnore.js +179 -0
- package/dist/esm/client/DockerRequestError.js +20 -0
- package/dist/esm/client/DockerStreams.js +111 -0
- package/dist/esm/client/types/ContainerCreateResponse.js +1 -0
- package/dist/esm/client/types/ContainerStopQuery.js +1 -0
- package/dist/esm/client/types/DeviceMapping.js +1 -0
- package/dist/esm/client/types/IdResponse.js +1 -0
- package/dist/esm/client/types/NetworkCreateResponse.js +1 -0
- package/dist/esm/client/types/PortBinding.js +1 -0
- package/dist/esm/docker/ConnectionOptionsBuilder.js +142 -0
- package/dist/esm/docker/Docker.js +697 -0
- package/dist/esm/docker/exceptions/DockerConnectionException.js +12 -0
- package/dist/esm/docker/exceptions/DockerContainerNotFoundException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageBuildException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageImportException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImageNotFoundException.js +13 -0
- package/dist/esm/docker/exceptions/DockerImagePullException.js +12 -0
- package/dist/esm/docker/exceptions/DockerImagePushException.js +11 -0
- package/dist/esm/docker/exceptions/DockerImageRepoTagNotFoundException.js +11 -0
- package/dist/esm/docker/exceptions/DockerNetworkNotFoundException.js +12 -0
- package/dist/esm/docker/exceptions/DockerRequestException.js +20 -0
- package/dist/esm/docker/interfaces/IDockerConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerHttpConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerHttpsConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerKeyObject.js +1 -0
- package/dist/esm/docker/interfaces/IDockerSSHConnectionOptions.js +1 -0
- package/dist/esm/docker/interfaces/IDockerSocketConnectionOptions.js +1 -0
- package/dist/esm/docker/lib/DockerContainer.js +739 -0
- package/dist/esm/docker/lib/DockerContainerTTY.js +154 -0
- package/dist/esm/docker/lib/DockerImage.js +270 -0
- package/dist/esm/docker/lib/EngineSettings.js +78 -0
- package/dist/esm/docker/lib/ParseBaseImages.js +47 -0
- package/dist/esm/docker/lib/ParseEnvToRecord.js +22 -0
- package/dist/esm/docker/lib/ParseRepositoryTag.js +45 -0
- package/dist/esm/docker/lib/RegistryAuth.js +12 -0
- package/dist/esm/docker/options/DockerPruneOptions.js +43 -0
- package/dist/esm/docker/options/auth/DockerAuthOptions.js +55 -0
- package/dist/esm/docker/options/container/ContainerCommitOptions.js +35 -0
- package/dist/esm/docker/options/container/ContainerCreateTTYOptions.js +39 -0
- package/dist/esm/docker/options/container/ContainerExecOptions.js +34 -0
- package/dist/esm/docker/options/container/ContainerExportDirectoryOptions.js +35 -0
- package/dist/esm/docker/options/container/ContainerKillOptions.js +32 -0
- package/dist/esm/docker/options/container/ContainerLogsOptions.js +52 -0
- package/dist/esm/docker/options/container/ContainerRemoveOptions.js +30 -0
- package/dist/esm/docker/options/container/ContainerSettingOptions.js +132 -0
- package/dist/esm/docker/options/container/ContainerStopOptions.js +36 -0
- package/dist/esm/docker/options/container/ContainerTTYConsoleSizeOptions.js +36 -0
- package/dist/esm/docker/options/image/ImageBuildOptions.js +107 -0
- package/dist/esm/docker/options/image/ImageExportOptions.js +40 -0
- package/dist/esm/docker/options/image/ImageImportOptions.js +38 -0
- package/dist/esm/docker/options/image/ImagePullOptions.js +59 -0
- package/dist/esm/docker/options/image/ImagePushOptions.js +52 -0
- package/dist/esm/docker/options/image/ImageRemoveOptions.js +34 -0
- package/dist/esm/docker/options/image/ImageTagOptions.js +34 -0
- package/dist/esm/docker/options/network/NetworkCreateOptions.js +59 -0
- package/dist/esm/docker/types/ContainerBind.js +1 -0
- package/dist/esm/docker/types/ContainerCapability.js +287 -0
- package/dist/esm/docker/types/ContainerConfig.js +1 -0
- package/dist/esm/docker/types/ContainerDevice.js +1 -0
- package/dist/esm/docker/types/ContainerExecResult.js +1 -0
- package/dist/esm/docker/types/ContainerNetwork.js +1 -0
- package/dist/esm/docker/types/ContainerPort.js +1 -0
- package/dist/esm/docker/types/ContainerRestartPolicy.js +1 -0
- package/dist/esm/docker/types/ContainerState.js +1 -0
- package/dist/esm/docker/types/ContainerStats.js +1 -0
- package/dist/esm/docker/types/DockerOutputCallback.js +1 -0
- package/dist/esm/docker/types/ImageConfig.js +1 -0
- package/dist/esm/docker/types/ImageExposePort.js +1 -0
- package/dist/esm/docker/types/NetworkInfo.js +1 -0
- package/dist/esm/docker/types/RepositoryTag.js +1 -0
- package/dist/esm/exports/Docker.js +73 -0
- package/dist/types/client/BuildContext.d.ts +22 -0
- package/dist/types/client/BuildKitProgress.d.ts +81 -0
- package/dist/types/client/DockerClient.d.ts +196 -0
- package/dist/types/client/DockerConnection.d.ts +154 -0
- package/dist/types/client/DockerIgnore.d.ts +44 -0
- package/dist/types/client/DockerRequestError.d.ts +17 -0
- package/dist/types/client/DockerStreams.d.ts +35 -0
- package/dist/types/client/types/ContainerCreateResponse.d.ts +7 -0
- package/dist/types/client/types/ContainerStopQuery.d.ts +13 -0
- package/dist/types/client/types/DeviceMapping.d.ts +8 -0
- package/dist/types/client/types/IdResponse.d.ts +6 -0
- package/dist/types/client/types/NetworkCreateResponse.d.ts +7 -0
- package/dist/types/client/types/PortBinding.d.ts +10 -0
- package/dist/types/docker/ConnectionOptionsBuilder.d.ts +128 -0
- package/dist/types/docker/Docker.d.ts +301 -0
- package/dist/types/docker/exceptions/DockerConnectionException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerContainerNotFoundException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageBuildException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageImportException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImageNotFoundException.d.ts +10 -0
- package/dist/types/docker/exceptions/DockerImagePullException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerImagePushException.d.ts +8 -0
- package/dist/types/docker/exceptions/DockerImageRepoTagNotFoundException.d.ts +8 -0
- package/dist/types/docker/exceptions/DockerNetworkNotFoundException.d.ts +9 -0
- package/dist/types/docker/exceptions/DockerRequestException.d.ts +22 -0
- package/dist/types/docker/interfaces/IDockerConnectionOptions.d.ts +75 -0
- package/dist/types/docker/interfaces/IDockerHttpConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerHttpsConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerKeyObject.d.ts +14 -0
- package/dist/types/docker/interfaces/IDockerSSHConnectionOptions.d.ts +16 -0
- package/dist/types/docker/interfaces/IDockerSocketConnectionOptions.d.ts +7 -0
- package/dist/types/docker/lib/DockerContainer.d.ts +315 -0
- package/dist/types/docker/lib/DockerContainerTTY.d.ts +99 -0
- package/dist/types/docker/lib/DockerImage.d.ts +153 -0
- package/dist/types/docker/lib/EngineSettings.d.ts +41 -0
- package/dist/types/docker/lib/ParseBaseImages.d.ts +9 -0
- package/dist/types/docker/lib/ParseEnvToRecord.d.ts +14 -0
- package/dist/types/docker/lib/ParseRepositoryTag.d.ts +17 -0
- package/dist/types/docker/lib/RegistryAuth.d.ts +8 -0
- package/dist/types/docker/options/DockerPruneOptions.d.ts +38 -0
- package/dist/types/docker/options/auth/DockerAuthOptions.d.ts +46 -0
- package/dist/types/docker/options/container/ContainerCommitOptions.d.ts +28 -0
- package/dist/types/docker/options/container/ContainerCreateTTYOptions.d.ts +32 -0
- package/dist/types/docker/options/container/ContainerExecOptions.d.ts +26 -0
- package/dist/types/docker/options/container/ContainerExportDirectoryOptions.d.ts +27 -0
- package/dist/types/docker/options/container/ContainerKillOptions.d.ts +25 -0
- package/dist/types/docker/options/container/ContainerLogsOptions.d.ts +48 -0
- package/dist/types/docker/options/container/ContainerRemoveOptions.d.ts +22 -0
- package/dist/types/docker/options/container/ContainerSettingOptions.d.ts +137 -0
- package/dist/types/docker/options/container/ContainerStopOptions.d.ts +28 -0
- package/dist/types/docker/options/container/ContainerTTYConsoleSizeOptions.d.ts +26 -0
- package/dist/types/docker/options/image/ImageBuildOptions.d.ts +117 -0
- package/dist/types/docker/options/image/ImageExportOptions.d.ts +33 -0
- package/dist/types/docker/options/image/ImageImportOptions.d.ts +28 -0
- package/dist/types/docker/options/image/ImagePullOptions.d.ts +49 -0
- package/dist/types/docker/options/image/ImagePushOptions.d.ts +41 -0
- package/dist/types/docker/options/image/ImageRemoveOptions.d.ts +26 -0
- package/dist/types/docker/options/image/ImageTagOptions.d.ts +25 -0
- package/dist/types/docker/options/network/NetworkCreateOptions.d.ts +54 -0
- package/dist/types/docker/types/ContainerBind.d.ts +19 -0
- package/dist/types/docker/types/ContainerCapability.d.ts +286 -0
- package/dist/types/docker/types/ContainerConfig.d.ts +67 -0
- package/dist/types/docker/types/ContainerDevice.d.ts +19 -0
- package/dist/types/docker/types/ContainerExecResult.d.ts +20 -0
- package/dist/types/docker/types/ContainerNetwork.d.ts +46 -0
- package/dist/types/docker/types/ContainerPort.d.ts +25 -0
- package/dist/types/docker/types/ContainerRestartPolicy.d.ts +11 -0
- package/dist/types/docker/types/ContainerState.d.ts +48 -0
- package/dist/types/docker/types/ContainerStats.d.ts +408 -0
- package/dist/types/docker/types/DockerOutputCallback.d.ts +8 -0
- package/dist/types/docker/types/ImageConfig.d.ts +34 -0
- package/dist/types/docker/types/ImageExposePort.d.ts +17 -0
- package/dist/types/docker/types/NetworkInfo.d.ts +59 -0
- package/dist/types/docker/types/RepositoryTag.d.ts +15 -0
- package/dist/types/exports/Docker.d.ts +73 -0
- package/package.json +57 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IDockerConnectionOptions } from './IDockerConnectionOptions.js';
|
|
2
|
+
/**
|
|
3
|
+
* The options of {@link buildDockerHttpsConnectionOptions}: a daemon reached over HTTPS at `host` and `port`, with the
|
|
4
|
+
* `ca`, `cert` and `key` (PEM contents), the headers, the timeout and the API version of
|
|
5
|
+
* {@link IDockerConnectionOptions} (its `protocol` is replaced by `'https'`).
|
|
6
|
+
*/
|
|
7
|
+
export interface IDockerHttpsConnectionOptions extends Omit<IDockerConnectionOptions, 'socketPath' | 'sshAuthAgent'> {
|
|
8
|
+
/**
|
|
9
|
+
* The host name or IP address of the daemon, as its certificate names it.
|
|
10
|
+
*/
|
|
11
|
+
host: string;
|
|
12
|
+
/**
|
|
13
|
+
* The TCP port of the daemon (2376 by convention).
|
|
14
|
+
*/
|
|
15
|
+
port: number | string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A private key of the HTTPS connections to the daemon, with its passphrase (the `key` option of {@link Docker}).
|
|
3
|
+
*/
|
|
4
|
+
export interface IDockerKeyObject {
|
|
5
|
+
/**
|
|
6
|
+
* The private key: its PEM contents, not its file path.
|
|
7
|
+
*/
|
|
8
|
+
pem: string | Buffer;
|
|
9
|
+
/**
|
|
10
|
+
* The passphrase decrypting the key.
|
|
11
|
+
* @default undefined (an unencrypted key)
|
|
12
|
+
*/
|
|
13
|
+
passphrase?: string | undefined;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IDockerConnectionOptions } from './IDockerConnectionOptions.js';
|
|
2
|
+
/**
|
|
3
|
+
* The options of {@link buildDockerSSHConnectionOptions}: a remote host reached over SSH at `host` and `port`, as
|
|
4
|
+
* `username`, authenticated by the SSH agent (`sshAuthAgent`), with the timeout and the API version of
|
|
5
|
+
* {@link IDockerConnectionOptions} (its `protocol` is replaced by `'ssh'`).
|
|
6
|
+
*/
|
|
7
|
+
export interface IDockerSSHConnectionOptions extends Omit<IDockerConnectionOptions, 'socketPath'> {
|
|
8
|
+
/**
|
|
9
|
+
* The host name or IP address of the remote host running the daemon.
|
|
10
|
+
*/
|
|
11
|
+
host: string;
|
|
12
|
+
/**
|
|
13
|
+
* The SSH port of the remote host (usually 22).
|
|
14
|
+
*/
|
|
15
|
+
port: number | string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDockerConnectionOptions } from './IDockerConnectionOptions.js';
|
|
2
|
+
/**
|
|
3
|
+
* The options of {@link buildDockerSocketConnectionOptions}: the daemon's Unix socket or named pipe (`socketPath`), with
|
|
4
|
+
* the authorities (`ca`), the timeout and the API version of {@link IDockerConnectionOptions}.
|
|
5
|
+
*/
|
|
6
|
+
export interface IDockerSocketConnectionOptions extends Omit<IDockerConnectionOptions, 'sshAuthAgent' | 'key' | 'protocol' | 'cert' | 'headers' | 'username' | 'port' | 'host'> {
|
|
7
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { Provider } from '@lakutata/core';
|
|
2
|
+
import type { DockerClient } from '../../client/DockerClient.js';
|
|
3
|
+
import { Time } from '@lakutata/utils/Time';
|
|
4
|
+
import { ContainerState } from '../types/ContainerState.js';
|
|
5
|
+
import { type Docker } from '../Docker.js';
|
|
6
|
+
import { type DockerImage } from './DockerImage.js';
|
|
7
|
+
import { ContainerNetwork } from '../types/ContainerNetwork.js';
|
|
8
|
+
import { ContainerPort } from '../types/ContainerPort.js';
|
|
9
|
+
import { ContainerBind } from '../types/ContainerBind.js';
|
|
10
|
+
import { ContainerDevice } from '../types/ContainerDevice.js';
|
|
11
|
+
import { ContainerStopOptions } from '../options/container/ContainerStopOptions.js';
|
|
12
|
+
import { ContainerRemoveOptions } from '../options/container/ContainerRemoveOptions.js';
|
|
13
|
+
import { ContainerSettingOptions } from '../options/container/ContainerSettingOptions.js';
|
|
14
|
+
import { ContainerRestartPolicy } from '../types/ContainerRestartPolicy.js';
|
|
15
|
+
import { type ContainerExecResult } from '../types/ContainerExecResult.js';
|
|
16
|
+
import { ContainerKillOptions } from '../options/container/ContainerKillOptions.js';
|
|
17
|
+
import { ContainerCommitOptions } from '../options/container/ContainerCommitOptions.js';
|
|
18
|
+
import { ContainerCapability } from '../types/ContainerCapability.js';
|
|
19
|
+
import { DockerContainerTTY } from './DockerContainerTTY.js';
|
|
20
|
+
import { ContainerCreateTTYOptions } from '../options/container/ContainerCreateTTYOptions.js';
|
|
21
|
+
import { ContainerLogsOptions } from '../options/container/ContainerLogsOptions.js';
|
|
22
|
+
import { ContainerStats } from '../types/ContainerStats.js';
|
|
23
|
+
import { ContainerExecOptions } from '../options/container/ContainerExecOptions.js';
|
|
24
|
+
import { ContainerExportDirectoryOptions } from '../options/container/ContainerExportDirectoryOptions.js';
|
|
25
|
+
/**
|
|
26
|
+
* A container of the Docker daemon, with its settings and its state as inspected, and its operations: start, stop,
|
|
27
|
+
* restart, pause, kill, remove, update, commit, exec, TTYs, logs, stats and the export of its files. It is not created
|
|
28
|
+
* with `new`: {@link Docker.getContainer}, {@link Docker.listContainers}, {@link Docker.createContainer} and
|
|
29
|
+
* {@link DockerImage.run} return it.
|
|
30
|
+
*
|
|
31
|
+
* Its properties are a snapshot, taken when it is obtained and refreshed by its own operations (`start()`, `stop()`,
|
|
32
|
+
* `restart()`, `pause()`, `unpause()`, `kill()`, `update()`): the changes made by others (the container exiting,
|
|
33
|
+
* `docker stop`) are seen by getting it again. Its operations reject with {@link DockerContainerNotFoundException} when
|
|
34
|
+
* the container was removed, with {@link DockerRequestException} when the daemon refuses them otherwise (not running:
|
|
35
|
+
* HTTP 409), and with the network error of Node.js when the daemon cannot be reached.
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import {type Docker, type DockerContainer, type DockerImage} from 'lakutata/com/docker'
|
|
39
|
+
*
|
|
40
|
+
* declare const docker: Docker
|
|
41
|
+
*
|
|
42
|
+
* const image: DockerImage = await docker.getImage('alpine:3.20')
|
|
43
|
+
* const container: DockerContainer = await docker.createContainer(image.id, {
|
|
44
|
+
* name: 'worker',
|
|
45
|
+
* cmd: ['sh', '-c', 'echo started; sleep 3600'],
|
|
46
|
+
* env: {MODE: 'production'},
|
|
47
|
+
* ports: [{port: 8080, type: 'tcp', hostPorts: [18080]}],
|
|
48
|
+
* binds: [{hostPath: '/srv/data', containerPath: '/data', rw: true}],
|
|
49
|
+
* restartPolicy: 'unless-stopped'
|
|
50
|
+
* })
|
|
51
|
+
* await container.start()
|
|
52
|
+
* console.log(container.state.status, container.ports)
|
|
53
|
+
* //The exit code, stdout and stderr
|
|
54
|
+
* const {exitCode, stdout} = await container.exec({cmd: ['ls', '/data']})
|
|
55
|
+
* console.log(exitCode, stdout)
|
|
56
|
+
* await container.stop({timeout: 10})
|
|
57
|
+
* await container.remove()
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class DockerContainer extends Provider {
|
|
61
|
+
#private;
|
|
62
|
+
/**
|
|
63
|
+
* Give the client of the Engine API: set by the {@link Docker} component creating the object.
|
|
64
|
+
*/
|
|
65
|
+
protected readonly getClient: () => DockerClient;
|
|
66
|
+
/**
|
|
67
|
+
* Give the {@link Docker} component which created the object.
|
|
68
|
+
*/
|
|
69
|
+
protected readonly getDocker: () => Docker;
|
|
70
|
+
/**
|
|
71
|
+
* The full ID of the container (64 hexadecimal characters). It changes when {@link DockerContainer.update}
|
|
72
|
+
* recreates the container.
|
|
73
|
+
*/
|
|
74
|
+
id: string;
|
|
75
|
+
/**
|
|
76
|
+
* The name of the container, without the leading `/` of the Engine API.
|
|
77
|
+
*/
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* The host name of the container (its short ID unless set when it was created).
|
|
81
|
+
*/
|
|
82
|
+
hostname: string;
|
|
83
|
+
/**
|
|
84
|
+
* The image the container was created from; `undefined` when it no longer exists (removed with force while the
|
|
85
|
+
* container was stopped).
|
|
86
|
+
*/
|
|
87
|
+
image: DockerImage | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* How many times the daemon restarted the container, by its restart policy.
|
|
90
|
+
*/
|
|
91
|
+
restartCount: number;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the container has full access to the host (`--privileged`).
|
|
94
|
+
*/
|
|
95
|
+
privileged: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the container's main process has a TTY: its logs are then raw, not split into stdout and stderr.
|
|
98
|
+
*/
|
|
99
|
+
tty: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* The environment variables of the container, the image's included, by name.
|
|
102
|
+
*/
|
|
103
|
+
env: Record<string, string>;
|
|
104
|
+
/**
|
|
105
|
+
* The memory limit of the container, in bytes; `0` for no limit.
|
|
106
|
+
*/
|
|
107
|
+
memoryLimit: number;
|
|
108
|
+
/**
|
|
109
|
+
* The indexes of the CPUs the container may run on, sorted; empty for all of them.
|
|
110
|
+
*/
|
|
111
|
+
cpuSet: number[];
|
|
112
|
+
/**
|
|
113
|
+
* When the daemon restarts the container after it exits (`'no'` by default; `'on-failure:3'` for 3 retries at
|
|
114
|
+
* most).
|
|
115
|
+
*/
|
|
116
|
+
restartPolicy: ContainerRestartPolicy;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the OOM killer is disabled for the container.
|
|
119
|
+
*/
|
|
120
|
+
OOMKillDisable: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* The kernel capabilities added to the container (`--cap-add`).
|
|
123
|
+
*/
|
|
124
|
+
capabilities: ContainerCapability[];
|
|
125
|
+
/**
|
|
126
|
+
* The state of the container: its status (`'created'`, `'running'`, `'exited'`…), its process ID, its exit code
|
|
127
|
+
* and its start and finish times.
|
|
128
|
+
*/
|
|
129
|
+
state: ContainerState;
|
|
130
|
+
/**
|
|
131
|
+
* The ports of the container, exposed by its image or published: one entry per IP address of the container, port
|
|
132
|
+
* and protocol, with the ports of the host published to it, each one once (empty when not published).
|
|
133
|
+
*/
|
|
134
|
+
ports: ContainerPort[];
|
|
135
|
+
/**
|
|
136
|
+
* The directories and files of the host mounted in the container (the bind mounts; not the volumes).
|
|
137
|
+
*/
|
|
138
|
+
binds: ContainerBind[];
|
|
139
|
+
/**
|
|
140
|
+
* The devices of the host added to the container.
|
|
141
|
+
*/
|
|
142
|
+
devices: ContainerDevice[];
|
|
143
|
+
/**
|
|
144
|
+
* The networks the container is connected to, with its addresses in each.
|
|
145
|
+
*/
|
|
146
|
+
networks: ContainerNetwork[];
|
|
147
|
+
/**
|
|
148
|
+
* The cgroup the container joins (`container:<name|id>`), as the daemon reports it (an empty string by default).
|
|
149
|
+
*/
|
|
150
|
+
cgroup: string | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* The parent cgroup under which the container's cgroup is created (an empty string by default).
|
|
153
|
+
*/
|
|
154
|
+
cgroupParent: string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* The PID namespace mode of the container: `'host'`, `'container:<name|id>'`, or an empty string for its own.
|
|
157
|
+
*/
|
|
158
|
+
pidMode: string | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* When the container was created.
|
|
161
|
+
*/
|
|
162
|
+
createdAt: Time;
|
|
163
|
+
/**
|
|
164
|
+
* Inspect the container.
|
|
165
|
+
* @throws {DockerContainerNotFoundException} When the container does not exist.
|
|
166
|
+
* @protected
|
|
167
|
+
*/
|
|
168
|
+
protected init(): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* Abort the requests in progress of the object (the container itself is left as it is).
|
|
171
|
+
* @protected
|
|
172
|
+
*/
|
|
173
|
+
protected destroy(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Refresh the properties from the daemon's inspection of the container, and its image (`undefined` when it no longer
|
|
176
|
+
* exists).
|
|
177
|
+
* @throws {DockerContainerNotFoundException} When the container does not exist.
|
|
178
|
+
* @protected
|
|
179
|
+
*/
|
|
180
|
+
protected syncContainerInfo(): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Start the container, as `docker start`, then refresh its properties. A container already running is left as it is
|
|
183
|
+
* (as the Docker CLI does).
|
|
184
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
185
|
+
* @throws {DockerRequestException} When it fails to start (HTTP 500: a command not found, a port already used).
|
|
186
|
+
*/
|
|
187
|
+
start(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Stop the container, as `docker stop`: send its stop signal, wait for it to exit, kill it after the timeout; then
|
|
190
|
+
* refresh its properties.
|
|
191
|
+
* @param options The signal sent (the container's stop signal, `SIGTERM` by default) and the timeout before the kill,
|
|
192
|
+
* in seconds (the container's, 10 by default). A container already stopped is left as it is (as the Docker CLI does).
|
|
193
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
194
|
+
*/
|
|
195
|
+
stop(options?: ContainerStopOptions): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Suspend the processes of the container, as `docker pause`, then refresh its properties.
|
|
198
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
199
|
+
* @throws {DockerRequestException} When it is not running or already paused (HTTP 409).
|
|
200
|
+
*/
|
|
201
|
+
pause(): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Resume the processes of a paused container, as `docker unpause`, then refresh its properties.
|
|
204
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
205
|
+
* @throws {DockerRequestException} When it is not paused (HTTP 409).
|
|
206
|
+
*/
|
|
207
|
+
unpause(): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Restart the container, as `docker restart`: stop it as {@link DockerContainer.stop} does (when it runs), then start
|
|
210
|
+
* it; then refresh its properties.
|
|
211
|
+
* @param options The signal sent (the container's stop signal, `SIGTERM` by default) and the timeout before the kill,
|
|
212
|
+
* in seconds (the container's, 10 by default).
|
|
213
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
214
|
+
* @throws {DockerRequestException} When it fails to start (HTTP 500).
|
|
215
|
+
*/
|
|
216
|
+
restart(options?: ContainerStopOptions): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Remove the container, as `docker rm -v`: its anonymous volumes are removed with it. The object is not refreshed:
|
|
219
|
+
* its other operations then fail with {@link DockerContainerNotFoundException}.
|
|
220
|
+
* @param options `force` kills a running container first (`false` by default).
|
|
221
|
+
* @throws {DockerContainerNotFoundException} When the container was already removed.
|
|
222
|
+
* @throws {DockerRequestException} When it is running and `force` is not set (HTTP 409).
|
|
223
|
+
*/
|
|
224
|
+
remove(options?: ContainerRemoveOptions): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Change the settings of the container, keeping the others. The memory limit, the CPUs and the restart policy are
|
|
227
|
+
* changed live, as `docker update` does, and the name by renaming it, the container running on. The other
|
|
228
|
+
* settings (and removing the memory limit or the CPU set, which Docker cannot do live) recreate the container: a new
|
|
229
|
+
* one is created from the old one's whole configuration (its image, command, entrypoint, environment, mounts,
|
|
230
|
+
* networks and their static addresses, the addresses Docker assigned being assigned again), with the settings
|
|
231
|
+
* changed, under a temporary name. Once created (and, when the old one was running, the old one stopped and the new
|
|
232
|
+
* one started), the old one is removed without its volumes and the new one takes its name (and its anonymous
|
|
233
|
+
* volumes, mounted again). The object follows the new container: its `id` changes.
|
|
234
|
+
* @remarks The old container is kept when the creation or the start of the new one fails (invalid settings, the
|
|
235
|
+
* image removed, a network missing): the new one is removed, the old one started again when it was running, and the
|
|
236
|
+
* call rejects. Its files outside the volumes are not kept by a recreation (commit them first, see
|
|
237
|
+
* {@link DockerContainer.commit}). A container removed by Docker when it stops (`AutoRemove`) cannot be kept.
|
|
238
|
+
* @param options The settings changed: `memoryLimit`, `cpuSet` and `restartPolicy` live (the swap limit set to
|
|
239
|
+
* Docker's default with the memory), `name` by a renaming; `hostname`, `env` (replacing the container's variables;
|
|
240
|
+
* the image's are added again), `cmd`, `entrypoint`, `tty`, `privileged`, `ports`, `binds` (replacing the bind
|
|
241
|
+
* mounts, the volumes kept), `devices`, `networks` (replacing the networks), `capabilities`, `OOMKillDisable`,
|
|
242
|
+
* `cgroup`, `cgroupParent` and `pidMode` by a recreation. The settings absent are kept.
|
|
243
|
+
* @throws {InvalidMethodAcceptException} When the settings are invalid.
|
|
244
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
245
|
+
* @throws {DockerImageNotFoundException} When the container must be recreated and its image no longer exists.
|
|
246
|
+
* @throws {DockerNetworkNotFoundException} When a network of the settings is not found.
|
|
247
|
+
* @throws {DockerRequestException} When the daemon refuses the changes: a limit refused (HTTP 400), the name
|
|
248
|
+
* already used (HTTP 409), the new container failing to start (HTTP 500).
|
|
249
|
+
*/
|
|
250
|
+
update(options: ContainerSettingOptions): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Create an image from the container's current files, as `docker commit`.
|
|
253
|
+
* @param options The name of the image (`repoTag`, `repo:tag`; none by default) and whether the container is paused
|
|
254
|
+
* while it is committed (`pauseBeforeCommitting`, `true` by default).
|
|
255
|
+
* @returns The image created.
|
|
256
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
257
|
+
*/
|
|
258
|
+
commit(options?: ContainerCommitOptions): Promise<DockerImage>;
|
|
259
|
+
/**
|
|
260
|
+
* Start an interactive command with a TTY in the running container, as `docker exec -it`. The command runs until it
|
|
261
|
+
* exits (or its stream is closed): see {@link DockerContainerTTY}.
|
|
262
|
+
* @param options The command (`['/bin/sh']` by default; the program and its arguments, run as they are, or a command
|
|
263
|
+
* line, run by `/bin/sh -c`) and the initial console size.
|
|
264
|
+
* @returns The TTY, its command started.
|
|
265
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
266
|
+
* @throws {DockerRequestException} When the container is not running (HTTP 409).
|
|
267
|
+
*/
|
|
268
|
+
createTTY(options?: ContainerCreateTTYOptions): Promise<DockerContainerTTY>;
|
|
269
|
+
/**
|
|
270
|
+
* Read the logs of the container's main process, as `docker logs`: stdout and stderr in one stream, in their order
|
|
271
|
+
* (split from Docker's multiplexed format unless the container has a TTY).
|
|
272
|
+
* @remarks The logs are followed by default: the stream does not end while the container runs. Pass `follow: false`
|
|
273
|
+
* for the logs written so far.
|
|
274
|
+
* @param options `follow` (`true` by default), `since` and `until` (UNIX timestamps in seconds; `0`, no bound, by
|
|
275
|
+
* default), `timestamps` (`false` by default) and `tail` (a number of lines from the end; all by default).
|
|
276
|
+
* @returns The readable stream of the logs.
|
|
277
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
278
|
+
*/
|
|
279
|
+
logs(options?: ContainerLogsOptions): Promise<NodeJS.ReadableStream>;
|
|
280
|
+
/**
|
|
281
|
+
* Read the resource usage of the container once, as `docker stats --no-stream`: CPU, memory, network, block I/O and
|
|
282
|
+
* processes, as the Engine API reports them.
|
|
283
|
+
* @returns The statistics.
|
|
284
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
285
|
+
*/
|
|
286
|
+
stats(): Promise<ContainerStats>;
|
|
287
|
+
/**
|
|
288
|
+
* Run a command in the running container, as `docker exec` (no TTY, no stdin), and wait for it to exit. As the
|
|
289
|
+
* containerd component's, a command exiting with a non-zero code resolves too: check its `exitCode`.
|
|
290
|
+
* @param options The command: a program and its arguments (`['ls', '-l']`), run as they are, or a command line
|
|
291
|
+
* (`'ls /data | wc -l'`), run by `/bin/sh -c`.
|
|
292
|
+
* @returns The exit code of the command, its stdout and its stderr (a program not found: exit code `127` or `126`,
|
|
293
|
+
* the error in the output).
|
|
294
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
295
|
+
* @throws {DockerRequestException} When the container is not running or paused (HTTP 409).
|
|
296
|
+
*/
|
|
297
|
+
exec(options: ContainerExecOptions): Promise<ContainerExecResult>;
|
|
298
|
+
/**
|
|
299
|
+
* Send a signal to the container's main process, as `docker kill` (`SIGKILL` by default), then refresh its properties.
|
|
300
|
+
* @param options The signal sent: a name (`'SIGHUP'`) or a number (`1`); `SIGKILL` by default.
|
|
301
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
302
|
+
* @throws {DockerRequestException} When the container is not running (HTTP 409), or the signal is unknown.
|
|
303
|
+
*/
|
|
304
|
+
kill(options?: ContainerKillOptions): Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Copy a file or a directory out of the container as a tar archive, as `docker cp container:path -`. The container
|
|
307
|
+
* may be stopped.
|
|
308
|
+
* @param options The path in the container, and the `destination` of the archive: a file path (created or
|
|
309
|
+
* overwritten) or a writable stream (ended after the archive).
|
|
310
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
311
|
+
* @throws {DockerRequestException} When the path is not found in the container (HTTP 404).
|
|
312
|
+
* @throws {Error} The error of the destination.
|
|
313
|
+
*/
|
|
314
|
+
exportDirectory(options: ContainerExportDirectoryOptions): Promise<void>;
|
|
315
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Provider } from '@lakutata/core';
|
|
2
|
+
import stream from 'stream';
|
|
3
|
+
import type { DockerClient } from '../../client/DockerClient.js';
|
|
4
|
+
import { ContainerTTYConsoleSizeOptions } from '../options/container/ContainerTTYConsoleSizeOptions.js';
|
|
5
|
+
/**
|
|
6
|
+
* An interactive command running with a TTY in a container, as `docker exec -it`: what is written to it is the
|
|
7
|
+
* command's input, its output (stdout and stderr together, with the terminal's control sequences) is read from it. It is
|
|
8
|
+
* not created with `new`: {@link DockerContainer.createTTY} returns it, its command started.
|
|
9
|
+
*
|
|
10
|
+
* The command runs until it exits (`exit` written to a shell), or until the stream is closed (`tty.raw.end()`,
|
|
11
|
+
* `tty.raw.destroy()`); the stream then ends. A command which cannot be started (not found in the image) does not fail
|
|
12
|
+
* the creation: its error message is the output, then the stream ends. The write failures are logged by the
|
|
13
|
+
* application's `log` component, else by the console.
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import {type DockerContainer, type DockerContainerTTY} from 'lakutata/com/docker'
|
|
17
|
+
*
|
|
18
|
+
* declare const container: DockerContainer
|
|
19
|
+
*
|
|
20
|
+
* //A shell: /bin/sh by default
|
|
21
|
+
* const tty: DockerContainerTTY = await container.createTTY({consoleSize: {cols: 120, rows: 40}})
|
|
22
|
+
* tty.onData((chunk: Buffer): void => {
|
|
23
|
+
* process.stdout.write(chunk)
|
|
24
|
+
* })
|
|
25
|
+
* tty.raw.once('end', (): void => console.log('The shell exited'))
|
|
26
|
+
* tty.write('ls -l /\n')
|
|
27
|
+
* await tty.resize({cols: 160, rows: 50})
|
|
28
|
+
* tty.write('exit\n')
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class DockerContainerTTY extends Provider {
|
|
32
|
+
#private;
|
|
33
|
+
/**
|
|
34
|
+
* Give the client of the Engine API: set by the {@link DockerContainer} creating the object.
|
|
35
|
+
*/
|
|
36
|
+
protected readonly getClient: () => DockerClient;
|
|
37
|
+
/**
|
|
38
|
+
* The full ID of the container running the command.
|
|
39
|
+
*/
|
|
40
|
+
protected readonly containerId: string;
|
|
41
|
+
/**
|
|
42
|
+
* The command run: the program and its arguments (a program name alone as a string).
|
|
43
|
+
*/
|
|
44
|
+
protected readonly cmd: string | string[];
|
|
45
|
+
/**
|
|
46
|
+
* The size of the console when the command starts.
|
|
47
|
+
* @default undefined (chosen by the daemon)
|
|
48
|
+
*/
|
|
49
|
+
protected readonly initialConsoleSize?: ContainerTTYConsoleSizeOptions;
|
|
50
|
+
/**
|
|
51
|
+
* Create the execution of the command and start it, attached to its TTY.
|
|
52
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
53
|
+
* @throws {DockerRequestException} When the container is not running (HTTP 409).
|
|
54
|
+
* @protected
|
|
55
|
+
*/
|
|
56
|
+
protected init(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Close the stream of the TTY, which ends the command's input.
|
|
59
|
+
* @protected
|
|
60
|
+
*/
|
|
61
|
+
protected destroy(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* The stream of the TTY, both ways: written, the command's input; read, its output. Its `end` event tells that the
|
|
64
|
+
* command exited, once its output is read (with {@link DockerContainerTTY.onData} or a `data` listener).
|
|
65
|
+
*/
|
|
66
|
+
get raw(): stream.Duplex;
|
|
67
|
+
/**
|
|
68
|
+
* The stream of the TTY, typed as its writable side: the command's input.
|
|
69
|
+
*/
|
|
70
|
+
get writable(): stream.Writable;
|
|
71
|
+
/**
|
|
72
|
+
* The stream of the TTY, typed as its readable side: the command's output.
|
|
73
|
+
*/
|
|
74
|
+
get readable(): stream.Readable;
|
|
75
|
+
/**
|
|
76
|
+
* Change the size of the TTY's console, as a terminal window resized does (the command gets `SIGWINCH`).
|
|
77
|
+
* @param options The number of columns (`cols`) and rows (`rows`).
|
|
78
|
+
* @throws {DockerRequestException} When the command has exited (HTTP 404, no such exec; HTTP 500).
|
|
79
|
+
* @throws {DockerContainerNotFoundException} When the container was removed.
|
|
80
|
+
*/
|
|
81
|
+
resize(options: ContainerTTYConsoleSizeOptions): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Receive the command's output as it comes. Each call adds a handler.
|
|
84
|
+
* @param handler Called with each chunk of the output: raw bytes, the terminal's control sequences included.
|
|
85
|
+
*/
|
|
86
|
+
onData(handler: (chunk: Buffer) => void): void;
|
|
87
|
+
/**
|
|
88
|
+
* Write text to the command's input, as typed on its terminal (`'ls\n'` runs `ls` in a shell). A write failure is
|
|
89
|
+
* not thrown: it is logged as a warning by the `log` component (by the console without it).
|
|
90
|
+
* @param data The text written, UTF-8 encoded.
|
|
91
|
+
*/
|
|
92
|
+
write(data: string): void;
|
|
93
|
+
/**
|
|
94
|
+
* Write bytes to the command's input, as typed on its terminal. A write failure is not thrown: it is logged as a
|
|
95
|
+
* warning by the `log` component (by the console without it).
|
|
96
|
+
* @param data The bytes written.
|
|
97
|
+
*/
|
|
98
|
+
write(data: Buffer): void;
|
|
99
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Provider } from '@lakutata/core';
|
|
2
|
+
import type { DockerClient } from '../../client/DockerClient.js';
|
|
3
|
+
import { Time } from '@lakutata/utils/Time';
|
|
4
|
+
import { ImageConfig } from '../types/ImageConfig.js';
|
|
5
|
+
import { ImageTagOptions } from '../options/image/ImageTagOptions.js';
|
|
6
|
+
import { ImageExportOptions } from '../options/image/ImageExportOptions.js';
|
|
7
|
+
import { ImageRemoveOptions } from '../options/image/ImageRemoveOptions.js';
|
|
8
|
+
import { ImagePushOptions } from '../options/image/ImagePushOptions.js';
|
|
9
|
+
import type { Docker } from '../Docker.js';
|
|
10
|
+
import { ContainerSettingOptions } from '../options/container/ContainerSettingOptions.js';
|
|
11
|
+
import { type DockerContainer } from './DockerContainer.js';
|
|
12
|
+
/**
|
|
13
|
+
* An image of the Docker daemon, with its tags, platform, size and configuration as inspected, and its operations: tag,
|
|
14
|
+
* export, push, remove, and run a container. It is not created with `new`: {@link Docker.getImage},
|
|
15
|
+
* {@link Docker.listImages}, {@link Docker.pullImage}, {@link Docker.buildImage}, {@link Docker.importImage} and
|
|
16
|
+
* {@link DockerContainer.commit} return it.
|
|
17
|
+
*
|
|
18
|
+
* Its properties are a snapshot, taken when it is obtained and refreshed by `tag()` and `push()`. Its operations reject
|
|
19
|
+
* with {@link DockerImageNotFoundException} when the image was removed, with {@link DockerRequestException} when the
|
|
20
|
+
* daemon refuses them otherwise (used by a container: HTTP 409), and with the network error of Node.js when the daemon
|
|
21
|
+
* cannot be reached.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import {type Docker, type DockerContainer, type DockerImage} from 'lakutata/com/docker'
|
|
25
|
+
*
|
|
26
|
+
* declare const docker: Docker
|
|
27
|
+
*
|
|
28
|
+
* const image: DockerImage = await docker.buildImage({workdir: '/srv/app', files: ['Dockerfile', 'src', 'package.json'], repoTag: 'app:1.0.0'})
|
|
29
|
+
* console.log(image.id, image.platform, image.size, image.config.ports)
|
|
30
|
+
* await image.tag({repo: 'registry.example.com/team/app', tag: '1.0.0'})
|
|
31
|
+
* await image.push({
|
|
32
|
+
* repo: 'registry.example.com/team/app',
|
|
33
|
+
* tag: '1.0.0',
|
|
34
|
+
* auth: {serverAddress: 'registry.example.com', username: 'ci', password: 'secret'}
|
|
35
|
+
* })
|
|
36
|
+
* await image.export({destination: '/tmp/app-1.0.0.tar', repoTag: 'app:1.0.0'})
|
|
37
|
+
* const container: DockerContainer = await image.run({name: 'app', ports: [{port: 3000, type: 'tcp', hostPorts: [3000]}]})
|
|
38
|
+
* console.log(container.state.status)
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare class DockerImage extends Provider {
|
|
42
|
+
#private;
|
|
43
|
+
/**
|
|
44
|
+
* Give the client of the Engine API: set by the {@link Docker} component creating the object.
|
|
45
|
+
*/
|
|
46
|
+
protected readonly getClient: () => DockerClient;
|
|
47
|
+
/**
|
|
48
|
+
* Give the {@link Docker} component which created the object.
|
|
49
|
+
*/
|
|
50
|
+
protected readonly getDocker: () => Docker;
|
|
51
|
+
/**
|
|
52
|
+
* The full ID of the image (`sha256:…`).
|
|
53
|
+
*/
|
|
54
|
+
id: string;
|
|
55
|
+
/**
|
|
56
|
+
* The tags of the image (`['alpine:3.20', 'alpine:latest']`); empty for an untagged image.
|
|
57
|
+
*/
|
|
58
|
+
repoTags: string[];
|
|
59
|
+
/**
|
|
60
|
+
* When the image was built.
|
|
61
|
+
*/
|
|
62
|
+
createdAt: Time;
|
|
63
|
+
/**
|
|
64
|
+
* The CPU architecture of the image (`amd64`, `arm64`).
|
|
65
|
+
*/
|
|
66
|
+
arch: string;
|
|
67
|
+
/**
|
|
68
|
+
* The operating system of the image (`linux`).
|
|
69
|
+
*/
|
|
70
|
+
os: string;
|
|
71
|
+
/**
|
|
72
|
+
* The platform of the image, `os/arch` (`linux/arm64`): the one its containers are created for by
|
|
73
|
+
* {@link DockerImage.run}.
|
|
74
|
+
*/
|
|
75
|
+
platform: string;
|
|
76
|
+
/**
|
|
77
|
+
* The size of the image, in bytes.
|
|
78
|
+
*/
|
|
79
|
+
size: number;
|
|
80
|
+
/**
|
|
81
|
+
* The configuration of the image: its default host name, user, environment, command, entrypoint, volumes and exposed
|
|
82
|
+
* ports.
|
|
83
|
+
*/
|
|
84
|
+
config: ImageConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Inspect the image.
|
|
87
|
+
* @throws {DockerImageNotFoundException} When the image does not exist.
|
|
88
|
+
* @protected
|
|
89
|
+
*/
|
|
90
|
+
protected init(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Abort the export in progress of the object (the image itself is left as it is).
|
|
93
|
+
* @protected
|
|
94
|
+
*/
|
|
95
|
+
protected destroy(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Refresh the properties from the daemon's inspection of the image.
|
|
98
|
+
* @throws {DockerImageNotFoundException} When the image does not exist.
|
|
99
|
+
* @protected
|
|
100
|
+
*/
|
|
101
|
+
protected syncImageInfo(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Add a tag to the image, as `docker tag`, then refresh its properties. A tag already given to another image moves to
|
|
104
|
+
* this one.
|
|
105
|
+
* @param options The repository (`registry.example.com/team/app`) and the tag (`latest` by default).
|
|
106
|
+
* @throws {DockerImageNotFoundException} When the image was removed.
|
|
107
|
+
* @throws {DockerRequestException} When the name is invalid (HTTP 400).
|
|
108
|
+
*/
|
|
109
|
+
tag(options: ImageTagOptions): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Save the image as a tar archive, as `docker save`, which {@link Docker.importImage} loads. With `repoTag`, the
|
|
112
|
+
* archive holds that tag (restored when it is loaded); without it, the image is saved by ID, without its tags.
|
|
113
|
+
* @param options The `destination` (a file path, created or overwritten, or a writable stream, ended after the
|
|
114
|
+
* archive), the tag saved (`repoTag`), and `createRepoTagIfNotExists` (`true` by default) to add that tag to the image
|
|
115
|
+
* when it does not have it.
|
|
116
|
+
* @throws {DockerImageRepoTagNotFoundException} When the image does not have `repoTag` and
|
|
117
|
+
* `createRepoTagIfNotExists` is `false`.
|
|
118
|
+
* @throws {DockerImageNotFoundException} When the image was removed.
|
|
119
|
+
* @throws {Error} The error of the destination.
|
|
120
|
+
*/
|
|
121
|
+
export(options: ImageExportOptions): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Push the image to its registry, as `docker push`, and wait for its end. The image is first tagged `repo:tag` (the
|
|
124
|
+
* tag is kept afterwards).
|
|
125
|
+
* @param options The repository, with its registry (`registry.example.com/team/app`); the tag (`latest` by default);
|
|
126
|
+
* the registry credentials; and a callback receiving each progress message.
|
|
127
|
+
* @throws {DockerImagePushException} When the registry refuses the push (refused credentials, a repository not
|
|
128
|
+
* found).
|
|
129
|
+
* @throws {DockerImageNotFoundException} When the image was removed.
|
|
130
|
+
* @throws {DockerRequestException} When the daemon refuses to push it.
|
|
131
|
+
*/
|
|
132
|
+
push(options: ImagePushOptions): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Remove the image, as `docker rmi -f` by default: forced, it is removed with all its tags, even when a stopped
|
|
135
|
+
* container uses it.
|
|
136
|
+
* @param options `force` (`true` by default; `false` refuses an image with several tags or used by a container) and
|
|
137
|
+
* `noprune` (keeps its untagged parent images; `false` by default).
|
|
138
|
+
* @throws {DockerImageNotFoundException} When the image was already removed.
|
|
139
|
+
* @throws {DockerRequestException} When it is used by a running container or, without `force`, by any container or
|
|
140
|
+
* with several tags (HTTP 409).
|
|
141
|
+
*/
|
|
142
|
+
remove(options?: ImageRemoveOptions): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Create a container from the image, for its platform, then start it, as `docker run -d`.
|
|
145
|
+
* @param options The container's settings: name, command, environment, ports, binds, devices, networks, limits…
|
|
146
|
+
* @returns The container, started.
|
|
147
|
+
* @throws {DockerRequestException} When the name is already used (HTTP 409), or the start fails (HTTP 500: a command
|
|
148
|
+
* not found, a port already used); the container then stays created.
|
|
149
|
+
* @throws {DockerNetworkNotFoundException} When a network of the settings is not found.
|
|
150
|
+
* @throws {InvalidMethodAcceptException} When the settings are invalid.
|
|
151
|
+
*/
|
|
152
|
+
run(options: ContainerSettingOptions): Promise<DockerContainer>;
|
|
153
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ContainerSettingOptions } from '../options/container/ContainerSettingOptions.js';
|
|
2
|
+
import { type ContainerRestartPolicy } from '../types/ContainerRestartPolicy.js';
|
|
3
|
+
import { type DeviceMapping } from '../../client/types/DeviceMapping.js';
|
|
4
|
+
import { type PortBinding } from '../../client/types/PortBinding.js';
|
|
5
|
+
/**
|
|
6
|
+
* The restart policy of the Engine API: "on-failure:3" is the policy on-failure with 3 retries at most
|
|
7
|
+
* @param restartPolicy
|
|
8
|
+
*/
|
|
9
|
+
export declare function engineRestartPolicy(restartPolicy: ContainerRestartPolicy): {
|
|
10
|
+
Name: string;
|
|
11
|
+
MaximumRetryCount?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The restart policy of a container, from the one of the Engine API
|
|
15
|
+
* @param restartPolicy
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseRestartPolicy(restartPolicy?: {
|
|
18
|
+
Name?: string;
|
|
19
|
+
MaximumRetryCount?: number;
|
|
20
|
+
} | null): ContainerRestartPolicy;
|
|
21
|
+
/**
|
|
22
|
+
* The port bindings of the Engine API ("80/tcp": [{HostPort: "8080"}]): each host port once, null for a port published
|
|
23
|
+
* on no host port
|
|
24
|
+
* @param ports
|
|
25
|
+
*/
|
|
26
|
+
export declare function enginePortBindings(ports: NonNullable<ContainerSettingOptions['ports']>): Record<string, PortBinding[] | null>;
|
|
27
|
+
/**
|
|
28
|
+
* The bind mounts of the Engine API ("hostPath:containerPath:rw")
|
|
29
|
+
* @param binds
|
|
30
|
+
*/
|
|
31
|
+
export declare function engineBinds(binds: NonNullable<ContainerSettingOptions['binds']>): string[];
|
|
32
|
+
/**
|
|
33
|
+
* The devices of the Engine API
|
|
34
|
+
* @param devices
|
|
35
|
+
*/
|
|
36
|
+
export declare function engineDevices(devices: NonNullable<ContainerSettingOptions['devices']>): DeviceMapping[];
|
|
37
|
+
/**
|
|
38
|
+
* The endpoints of the Engine API, by network: the static addresses given, none on the reserved networks
|
|
39
|
+
* @param networks
|
|
40
|
+
*/
|
|
41
|
+
export declare function engineEndpoints(networks: NonNullable<ContainerSettingOptions['networks']>): Record<string, Record<string, unknown>>;
|