@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
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Lakutata
|
|
4
|
+
|
|
5
|
+
All rights reserved
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
# @lakutata/docker
|
|
2
|
+
|
|
3
|
+
The Docker component of the lakutata framework: it drives a Docker daemon over the Docker Engine API, without the
|
|
4
|
+
Docker CLI, to pull, build (with BuildKit), import, export, tag and push images, to create, run and manage containers
|
|
5
|
+
(exec, interactive TTYs, logs, stats, commit, file export) and to manage networks. It connects to a local socket, or to
|
|
6
|
+
a remote daemon over HTTP, HTTPS or SSH. The umbrella package `lakutata` re-exports it as `lakutata/com/docker`.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```shell
|
|
11
|
+
npm install lakutata
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The component needs a Docker daemon (Docker Engine or Docker Desktop, Engine API 1.41 or newer) reachable from the
|
|
15
|
+
application; no Docker CLI is needed locally. The SSH connections use the optional peer dependency `ssh2`, and the
|
|
16
|
+
Docker CLI on the remote host:
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
npm install ssh2
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Connection | Options | Needs |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| The Docker of the environment (default) | none: `DOCKER_HOST`, `DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, `DOCKER_CLIENT_TIMEOUT`, else the local socket | nothing |
|
|
25
|
+
| Unix socket / Windows named pipe | `socketPath` (`buildDockerSocketConnectionOptions`) | access to the socket (the `docker` group) |
|
|
26
|
+
| TCP, plain HTTP | `host`, `port` (`buildDockerHttpConnectionOptions`) | a daemon listening on TCP (`-H tcp://0.0.0.0:2375`) |
|
|
27
|
+
| TCP, HTTPS | `host`, `port`, `ca`, `cert`, `key` as PEM contents (`buildDockerHttpsConnectionOptions`) | a daemon with TLS (`--tlsverify`) |
|
|
28
|
+
| SSH | `host`, `port`, `username`, `sshAuthAgent` (`buildDockerSSHConnectionOptions`) | `ssh2` locally; the Docker CLI remotely; a key in the SSH agent |
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### The component in an application
|
|
33
|
+
|
|
34
|
+
Register `Docker` in the `components` of the application, then get it with `getObject()` or `@Inject`. When it is
|
|
35
|
+
created, the component pings the daemon and negotiates the API version: an unreachable daemon fails the launch with
|
|
36
|
+
`DockerConnectionException`.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import {Application} from 'lakutata'
|
|
40
|
+
import {Docker, type DockerContainer, type DockerImage} from 'lakutata/com/docker'
|
|
41
|
+
|
|
42
|
+
Application
|
|
43
|
+
.run(() => ({
|
|
44
|
+
id: 'docker.app',
|
|
45
|
+
name: 'Docker',
|
|
46
|
+
components: {
|
|
47
|
+
//The Docker of the environment: DOCKER_HOST, else the local socket
|
|
48
|
+
docker: {class: Docker}
|
|
49
|
+
}
|
|
50
|
+
}))
|
|
51
|
+
.onLaunched(async (app: Application): Promise<void> => {
|
|
52
|
+
const docker: Docker = await app.getObject('docker')
|
|
53
|
+
|
|
54
|
+
//Pulled, then looked up as alpine:3.20
|
|
55
|
+
const image: DockerImage = await docker.pullImage({repo: 'alpine', tag: '3.20'})
|
|
56
|
+
|
|
57
|
+
//Created, then started
|
|
58
|
+
const container: DockerContainer = await image.run({
|
|
59
|
+
name: 'hello',
|
|
60
|
+
cmd: ['sh', '-c', 'echo started; sleep 3600'],
|
|
61
|
+
env: {MODE: 'production'}
|
|
62
|
+
})
|
|
63
|
+
console.log(container.id, container.state.status)
|
|
64
|
+
|
|
65
|
+
//The exit code, stdout and stderr
|
|
66
|
+
const {exitCode, stdout} = await container.exec({cmd: ['cat', '/etc/alpine-release']})
|
|
67
|
+
console.log(exitCode, stdout)
|
|
68
|
+
|
|
69
|
+
await container.stop({timeout: 10})
|
|
70
|
+
await container.remove()
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Connections
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import {readFileSync} from 'node:fs'
|
|
78
|
+
import {Application} from 'lakutata'
|
|
79
|
+
import {
|
|
80
|
+
buildDockerHttpsConnectionOptions,
|
|
81
|
+
buildDockerSocketConnectionOptions,
|
|
82
|
+
buildDockerSSHConnectionOptions,
|
|
83
|
+
Docker
|
|
84
|
+
} from 'lakutata/com/docker'
|
|
85
|
+
|
|
86
|
+
Application.run(() => ({
|
|
87
|
+
id: 'docker.app',
|
|
88
|
+
name: 'Docker',
|
|
89
|
+
components: {
|
|
90
|
+
//A socket, with a request timeout of 60 s
|
|
91
|
+
local: buildDockerSocketConnectionOptions({socketPath: '/var/run/docker.sock', timeout: 60000}),
|
|
92
|
+
//TLS: the PEM contents, not the file paths
|
|
93
|
+
remote: buildDockerHttpsConnectionOptions({
|
|
94
|
+
host: 'docker.example.com',
|
|
95
|
+
port: 2376,
|
|
96
|
+
ca: readFileSync('/etc/docker/certs/ca.pem'),
|
|
97
|
+
cert: readFileSync('/etc/docker/certs/cert.pem'),
|
|
98
|
+
key: readFileSync('/etc/docker/certs/key.pem')
|
|
99
|
+
}),
|
|
100
|
+
//SSH: authenticated by the SSH agent (SSH_AUTH_SOCK)
|
|
101
|
+
builder: buildDockerSSHConnectionOptions({host: 'build.example.com', port: 22, username: 'deploy'}),
|
|
102
|
+
//The options as they are, with a fixed API version
|
|
103
|
+
pinned: {class: Docker, version: '1.47'}
|
|
104
|
+
}
|
|
105
|
+
}))
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Without `socketPath` nor `host`, the component connects to the Docker of the environment, with the other options
|
|
109
|
+
given (`timeout`, `headers`, `version`…) applied over the environment's.
|
|
110
|
+
- `protocol` defaults to `'https'` when `ca`, `cert` and `key` are all given, to `'http'` otherwise.
|
|
111
|
+
- `timeout` (milliseconds) is the time a request may stay idle; it also ends the streams (followed logs) idle for that
|
|
112
|
+
long.
|
|
113
|
+
|
|
114
|
+
### Images
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import {createReadStream} from 'node:fs'
|
|
118
|
+
import {type Docker, type DockerImage} from 'lakutata/com/docker'
|
|
119
|
+
|
|
120
|
+
declare const docker: Docker
|
|
121
|
+
|
|
122
|
+
//Pull, with the registry's credentials and the progress messages
|
|
123
|
+
const node: DockerImage = await docker.pullImage({
|
|
124
|
+
repo: 'registry.example.com/base/node',
|
|
125
|
+
tag: '22',
|
|
126
|
+
platform: 'linux/amd64',
|
|
127
|
+
auth: {serverAddress: 'registry.example.com', username: 'ci', password: 'secret'},
|
|
128
|
+
outputCallback: (output: Record<string, any>): void => console.log(output.status, output.progress ?? '')
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
//Build with BuildKit: the context is the files listed (directories with their content), minus .dockerignore
|
|
132
|
+
const app: DockerImage = await docker.buildImage({
|
|
133
|
+
workdir: '/srv/app',
|
|
134
|
+
files: ['Dockerfile', 'package.json', 'src'],
|
|
135
|
+
repoTag: 'app:1.0.0',
|
|
136
|
+
buildargs: {NODE_ENV: 'production'},
|
|
137
|
+
outputCallback: (output: Record<string, any>): void => console.log(output.stream ?? '')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
//Tag, push, save to an archive, load it back
|
|
141
|
+
await app.tag({repo: 'registry.example.com/team/app', tag: '1.0.0'})
|
|
142
|
+
await app.push({repo: 'registry.example.com/team/app', tag: '1.0.0', auth: {serverAddress: 'registry.example.com', username: 'ci', password: 'secret'}})
|
|
143
|
+
await app.export({destination: '/tmp/app.tar', repoTag: 'app:1.0.0'})
|
|
144
|
+
const loaded: DockerImage = await docker.importImage({source: createReadStream('/tmp/app.tar')})
|
|
145
|
+
|
|
146
|
+
//Look up by ID, short ID or name, list, remove (forced by default), prune
|
|
147
|
+
console.log((await docker.getImage('app:1.0.0')).id, loaded.repoTags, node.platform)
|
|
148
|
+
console.log((await docker.listImages()).map((image: DockerImage): string[] => image.repoTags))
|
|
149
|
+
await app.remove()
|
|
150
|
+
await docker.prune({containers: false, images: true, networks: false, volumes: false})
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- `getImage()` resolves the names as the daemon does: the full or short ID, `alpine` for `alpine:latest`,
|
|
154
|
+
`docker.io/library/alpine:3.20`, a digest; `pullImage()` finds the image pulled the same way.
|
|
155
|
+
- `listImages()` inspects every image: one request per image.
|
|
156
|
+
- `prune()` without options prunes the stopped containers and the dangling images; the unused networks and anonymous
|
|
157
|
+
volumes only when asked (`networks: true`, `volumes: true`).
|
|
158
|
+
- The registry credentials (`auth`) are sent whole, the tokens (`identityToken`, `registryToken`) included, by the
|
|
159
|
+
pulls, the builds, the pushes and `loginRepository()`.
|
|
160
|
+
|
|
161
|
+
### Containers
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import {createWriteStream} from 'node:fs'
|
|
165
|
+
import {type Docker, type DockerContainer, type DockerContainerTTY, type DockerImage} from 'lakutata/com/docker'
|
|
166
|
+
|
|
167
|
+
declare const docker: Docker
|
|
168
|
+
|
|
169
|
+
const image: DockerImage = await docker.getImage('nginx:1.27')
|
|
170
|
+
//Created, not started
|
|
171
|
+
const web: DockerContainer = await docker.createContainer(image.id, {
|
|
172
|
+
name: 'web',
|
|
173
|
+
hostname: 'web',
|
|
174
|
+
ports: [{port: 80, type: 'tcp', hostPorts: [8080]}],
|
|
175
|
+
binds: [{hostPath: '/srv/www', containerPath: '/usr/share/nginx/html', rw: false}],
|
|
176
|
+
networks: [{networkName: 'backend', ip: '172.30.0.10'}],
|
|
177
|
+
memoryLimit: 256 * 1024 * 1024,
|
|
178
|
+
cpuSet: [0, 1],
|
|
179
|
+
restartPolicy: 'unless-stopped'
|
|
180
|
+
})
|
|
181
|
+
await web.start()
|
|
182
|
+
|
|
183
|
+
//The logs so far (follow: true keeps the stream open while the container runs)
|
|
184
|
+
const logs: NodeJS.ReadableStream = await web.logs({follow: false, tail: 100, timestamps: true})
|
|
185
|
+
logs.pipe(process.stdout)
|
|
186
|
+
|
|
187
|
+
//One sample of CPU, memory, network and block I/O
|
|
188
|
+
console.log(await web.stats())
|
|
189
|
+
|
|
190
|
+
//A command line (run by /bin/sh -c), and its exit code
|
|
191
|
+
const {exitCode, stdout, stderr} = await web.exec({cmd: 'nginx -t && ls /etc/nginx | wc -l'})
|
|
192
|
+
console.log(exitCode, stdout, stderr)
|
|
193
|
+
|
|
194
|
+
//An interactive shell with a TTY (/bin/sh by default)
|
|
195
|
+
const tty: DockerContainerTTY = await web.createTTY({consoleSize: {cols: 120, rows: 40}})
|
|
196
|
+
tty.onData((chunk: Buffer): void => {
|
|
197
|
+
process.stdout.write(chunk)
|
|
198
|
+
})
|
|
199
|
+
tty.write('nginx -v\n')
|
|
200
|
+
await tty.resize({cols: 160, rows: 50})
|
|
201
|
+
tty.write('exit\n')
|
|
202
|
+
|
|
203
|
+
//A directory of the container as a tar archive; an image of its files
|
|
204
|
+
await web.exportDirectory({path: '/etc/nginx', destination: createWriteStream('/tmp/nginx-conf.tar')})
|
|
205
|
+
const snapshot: DockerImage = await web.commit({repoTag: 'web-snapshot:1'})
|
|
206
|
+
console.log(snapshot.id)
|
|
207
|
+
|
|
208
|
+
//The limits and the restart policy changed live; the other settings by recreating the container (its ID changes)
|
|
209
|
+
await web.update({memoryLimit: 512 * 1024 * 1024, restartPolicy: 'on-failure:3'})
|
|
210
|
+
await web.update({env: {TZ: 'UTC'}})
|
|
211
|
+
|
|
212
|
+
await web.restart({timeout: 5})
|
|
213
|
+
await web.kill({signal: 'SIGHUP'})
|
|
214
|
+
await web.pause()
|
|
215
|
+
await web.unpause()
|
|
216
|
+
await web.stop()
|
|
217
|
+
await web.remove({force: true})
|
|
218
|
+
|
|
219
|
+
//All the containers, the stopped ones included
|
|
220
|
+
console.log((await docker.listContainers()).map((container: DockerContainer): string => `${container.name}: ${container.state.status}`))
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
- A `DockerContainer` is a snapshot: its operations refresh it, the changes made by others are seen by getting it again
|
|
224
|
+
(`docker.getContainer(id)`, which also takes a name or a short ID). A container whose image was removed with force is
|
|
225
|
+
read without it: its `image` is `undefined`.
|
|
226
|
+
- Starting a running container or stopping a stopped one does nothing, as the Docker CLI.
|
|
227
|
+
- `exec()` runs without TTY nor stdin and resolves with `{exitCode, stdout, stderr}`, whatever the exit code (as the
|
|
228
|
+
containerd component's). An array command runs as it is; a string is a command line, run by `/bin/sh -c`.
|
|
229
|
+
- `createTTY()` runs `/bin/sh` by default; its `cmd` follows the rules of `exec()`. Its write failures are logged by the
|
|
230
|
+
application's `log` component, else by the console.
|
|
231
|
+
- `kill()` sends `SIGKILL` by default, or the signal given (`'SIGHUP'`, `15`).
|
|
232
|
+
- `update()` changes the memory limit, the CPUs and the restart policy live, and the name by renaming the container.
|
|
233
|
+
The other settings recreate it from its whole configuration (command, mounts, networks, the anonymous volumes
|
|
234
|
+
mounted again): created under a temporary name, it replaces the old one only once created (and started, when the
|
|
235
|
+
old one ran), so a failure leaves the old one as it was. Its ID changes; its files outside the volumes are not kept.
|
|
236
|
+
- `state.startedAt` and `state.finishedAt` are `null` when the container was never started or never exited.
|
|
237
|
+
- Not provided: attaching to the main process, copying files into a container, the volumes (other than by `prune()`)
|
|
238
|
+
and the daemon's events.
|
|
239
|
+
|
|
240
|
+
### Networks
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import {type Docker, type NetworkInfo} from 'lakutata/com/docker'
|
|
244
|
+
|
|
245
|
+
declare const docker: Docker
|
|
246
|
+
|
|
247
|
+
const network: NetworkInfo = await docker.createNetwork({
|
|
248
|
+
name: 'backend',
|
|
249
|
+
driver: 'bridge',
|
|
250
|
+
NetworkIPAMConfigs: [{subnet: '172.30.0.0/16', gateway: '172.30.0.1'}],
|
|
251
|
+
internal: false
|
|
252
|
+
})
|
|
253
|
+
//The subnet chosen by the daemon
|
|
254
|
+
await docker.createNetwork({name: 'frontend'})
|
|
255
|
+
console.log(network.id, network.IPAMConfigs)
|
|
256
|
+
//The drivers as Docker reports them: bridge, host, null, overlay…
|
|
257
|
+
console.log((await docker.listNetworks()).map((item: NetworkInfo): string => `${item.name}: ${item.driver}`))
|
|
258
|
+
//By ID, short ID or name
|
|
259
|
+
console.log((await docker.getNetwork('frontend')).id)
|
|
260
|
+
await docker.removeNetwork('frontend')
|
|
261
|
+
await docker.removeNetwork(network.id)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## API
|
|
265
|
+
|
|
266
|
+
| Export | What it is |
|
|
267
|
+
|---|---|
|
|
268
|
+
| `Docker` | The component: `pullImage`, `buildImage`, `importImage`, `getImage`, `listImages`, `createContainer`, `getContainer`, `listContainers`, `createNetwork`, `getNetwork`, `listNetworks`, `removeNetwork`, `prune`, `loginRepository`, `checkRepositoryAuth`; the connection options |
|
|
269
|
+
| `DockerImage` | An image: `id`, `repoTags`, `platform`, `size`, `config`; `tag()`, `export()`, `push()`, `remove()`, `run()` |
|
|
270
|
+
| `DockerContainer` | A container: its settings and `state`; `start()`, `stop()`, `restart()`, `pause()`, `unpause()`, `kill()`, `remove()`, `update()`, `commit()`, `exec()`, `createTTY()`, `logs()`, `stats()`, `exportDirectory()` |
|
|
271
|
+
| `DockerContainerTTY` | An interactive command with a TTY: `raw`, `readable`, `writable`, `onData()`, `write()`, `resize()` |
|
|
272
|
+
| `buildDockerConnectionOptions`, `buildDockerSocketConnectionOptions`, `buildDockerHttpConnectionOptions`, `buildDockerHttpsConnectionOptions`, `buildDockerSSHConnectionOptions` | Build the component options for each kind of connection |
|
|
273
|
+
| `IDockerConnectionOptions`, `IDockerSocketConnectionOptions`, `IDockerHttpConnectionOptions`, `IDockerHttpsConnectionOptions`, `IDockerSSHConnectionOptions`, `IDockerKeyObject` | The connection options |
|
|
274
|
+
| `ImagePullOptions`, `ImageBuildOptions`, `ImageImportOptions`, `ImageExportOptions`, `ImageTagOptions`, `ImagePushOptions`, `ImageRemoveOptions` | The options of the image operations |
|
|
275
|
+
| `ContainerSettingOptions`, `ContainerStopOptions`, `ContainerKillOptions`, `ContainerRemoveOptions`, `ContainerCommitOptions`, `ContainerExecOptions`, `ContainerCreateTTYOptions`, `ContainerTTYConsoleSizeOptions`, `ContainerLogsOptions`, `ContainerExportDirectoryOptions` | The options of the container operations |
|
|
276
|
+
| `NetworkCreateOptions`, `DockerPruneOptions`, `DockerAuthOptions` | The options of the networks, of `prune()`, and the registry credentials |
|
|
277
|
+
| `ContainerState`, `ContainerPort`, `ContainerBind`, `ContainerDevice`, `ContainerNetwork`, `ContainerCapability`, `ContainerRestartPolicy`, `ContainerStats`, `ContainerConfig`, `ContainerExecResult` | The types of the containers, and the result of `exec()` |
|
|
278
|
+
| `ImageConfig`, `ImageExposePort`, `RepositoryTag`, `NetworkInfo`, `DockerOutputCallback` | The types of the images, the networks and the progress messages |
|
|
279
|
+
| `parseRepositoryTag`, `parseEnvToRecord` | Split an image reference into repository and tag; turn `NAME=value` entries into a record |
|
|
280
|
+
| `DockerConnectionException`, `DockerContainerNotFoundException`, `DockerImageNotFoundException`, `DockerImagePullException`, `DockerImageBuildException`, `DockerImageImportException`, `DockerImagePushException`, `DockerImageRepoTagNotFoundException`, `DockerNetworkNotFoundException`, `DockerRequestException` | The exceptions |
|
|
281
|
+
|
|
282
|
+
All are exported by `lakutata/com/docker` and `@lakutata/docker`. The typings document each declaration with examples.
|
|
283
|
+
|
|
284
|
+
## Errors
|
|
285
|
+
|
|
286
|
+
| Exception | When |
|
|
287
|
+
|---|---|
|
|
288
|
+
| `DockerConnectionException` (`E_DOCKER_CONNECTION`) | The component's creation: the daemon unreachable or not answering, the TLS handshake failing, SSH without `ssh2` |
|
|
289
|
+
| `DockerContainerNotFoundException` (`E_DOCKER_CONTAINER_NOT_FOUND`) | `getContainer()` finds no container with this ID, short ID or name; an operation of a container removed |
|
|
290
|
+
| `DockerImageNotFoundException` (`E_DOCKER_IMAGE_NOT_FOUND`) | `getImage()` finds no image with this ID or name; `createContainer()` (or the recreation of `update()`) of a missing image; an operation of an image removed |
|
|
291
|
+
| `DockerImagePullException` (`E_DOCKER_IMAGE_PULL`) | `pullImage()` fails, or the component is destroyed during the pull |
|
|
292
|
+
| `DockerImageBuildException` (`E_DOCKER_IMAGE_BUILD`) | `buildImage()` fails: a step, a missing file, a base image which cannot be pulled, the component destroyed during the build |
|
|
293
|
+
| `DockerImageImportException` (`E_DOCKER_IMAGE_IMPORT`) | `importImage()`: the daemon rejects the archive, or the loaded image is unknown |
|
|
294
|
+
| `DockerImagePushException` (`E_DOCKER_IMAGE_PUSH`) | `push()`: the registry refuses the push |
|
|
295
|
+
| `DockerImageRepoTagNotFoundException` (`E_DOCKER_IMAGE_REPO_TAG_NOT_FOUND`) | `export()` of a tag the image does not have, with `createRepoTagIfNotExists: false` |
|
|
296
|
+
| `DockerNetworkNotFoundException` (`E_DOCKER_NETWORK_NOT_FOUND`) | `getNetwork()` or `removeNetwork()` with an ID, short ID or name no network has; a container created or recreated on a missing network |
|
|
297
|
+
| `DockerRequestException` (`E_DOCKER_REQUEST`) | The daemon refuses a request and no exception above fits: its `statusCode` is the HTTP status (409 a name already used or a container not running, 401 credentials refused by `loginRepository()`, 400 an invalid setting, 500…), its message the daemon's |
|
|
298
|
+
| `InvalidMethodAcceptException` (from `lakutata`) | The options of a call are invalid |
|
|
299
|
+
| The errors of Node.js | The daemon becomes unreachable after the component's creation (`ECONNREFUSED`…); the `source` file of `importImage()` cannot be read (`ENOENT`…) |
|
|
300
|
+
|
|
301
|
+
When the component is destroyed (the application stopping), the pulls and builds in progress are aborted and reject
|
|
302
|
+
with their exception; the listings in progress resolve with an empty list.
|
|
303
|
+
|
|
304
|
+
## See also
|
|
305
|
+
|
|
306
|
+
- `doc/en/DockerIntegration.md` of the package `lakutata` (Chinese in `doc/zh`): the guide of the Docker integration.
|
|
307
|
+
- `@lakutata/containerd` (`lakutata/com/containerd`): the same API without a Docker daemon, over containerd.
|
|
308
|
+
- `@lakutata/core` (`lakutata`): the components, `Application` and the dependency injection.
|
|
309
|
+
- `npm run test:docker` (in this package) tests the component against the Docker of the machine.
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Parts of `@lakutata/docker` are derived from the third-party projects listed below. They are rewritten in TypeScript
|
|
4
|
+
and modified; the original copyright notices and license terms are reproduced here as required.
|
|
5
|
+
|
|
6
|
+
## dockerode 4.0.9
|
|
7
|
+
|
|
8
|
+
Copyright Pedro Dias. Licensed under the Apache License, Version 2.0 (reproduced below).
|
|
9
|
+
|
|
10
|
+
The operations of the Docker Engine API: `src/client/DockerClient.ts`, and the preparation of the build contexts:
|
|
11
|
+
`src/client/BuildContext.ts`.
|
|
12
|
+
|
|
13
|
+
Modifications: rewritten in TypeScript with promises only; the query parameters and the bodies are separated; the
|
|
14
|
+
swarm, plugin and volume operations (except the prune of the volumes) are not included; the registry credentials of
|
|
15
|
+
the builds are sent by the `X-Registry-Config` header, without the gRPC session of BuildKit (no protobuf definitions
|
|
16
|
+
are included); the progress of BuildKit is decoded into readable lines (`src/client/BuildKitProgress.ts`).
|
|
17
|
+
|
|
18
|
+
## docker-modem 5.0.7
|
|
19
|
+
|
|
20
|
+
Copyright Pedro Dias. Licensed under the Apache License, Version 2.0 (reproduced below).
|
|
21
|
+
|
|
22
|
+
The connection to the Docker Engine API and its streams: `src/client/DockerConnection.ts`,
|
|
23
|
+
`src/client/DockerStreams.ts`, `src/client/DockerRequestError.ts`.
|
|
24
|
+
|
|
25
|
+
Modifications: rewritten in TypeScript with promises; the API version is negotiated with the daemon; the requests
|
|
26
|
+
streaming a body close their connection (`Connection: close`) so that the daemon cannot discard a part of a body on a
|
|
27
|
+
kept-alive connection; ssh2 is an optional peer dependency, loaded only for `ssh://` hosts.
|
|
28
|
+
|
|
29
|
+
## @balena/dockerignore 1.0.2
|
|
30
|
+
|
|
31
|
+
Copyright 2020 Balena Ltd. under the Apache License, Version 2.0 (reproduced below).
|
|
32
|
+
Copyright 2018 Zeit Inc. under the MIT License (reproduced below).
|
|
33
|
+
|
|
34
|
+
The rules of the `.dockerignore` files: `src/client/DockerIgnore.ts`.
|
|
35
|
+
|
|
36
|
+
Modifications: rewritten in TypeScript; only the matching of the paths of a build context is kept.
|
|
37
|
+
|
|
38
|
+
## tar-fs 2.1.4
|
|
39
|
+
|
|
40
|
+
The packing of the directories of the build contexts: `src/client/BuildContext.ts`.
|
|
41
|
+
|
|
42
|
+
Modifications: rewritten on tar-stream; each file is packed once, the files excluded by `.dockerignore` are skipped,
|
|
43
|
+
and an error of the packing fails the archive instead of ending it.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
The MIT License (MIT)
|
|
47
|
+
|
|
48
|
+
Copyright (c) 2014 Mathias Buus
|
|
49
|
+
|
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
51
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
52
|
+
in the Software without restriction, including without limitation the rights
|
|
53
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
54
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
55
|
+
furnished to do so, subject to the following conditions:
|
|
56
|
+
|
|
57
|
+
The above copyright notice and this permission notice shall be included in
|
|
58
|
+
all copies or substantial portions of the Software.
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
61
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
62
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
63
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
64
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
65
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
66
|
+
THE SOFTWARE.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## The MIT License of Zeit Inc.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Copyright 2018 Zeit Inc.
|
|
73
|
+
|
|
74
|
+
The MIT License (MIT)
|
|
75
|
+
|
|
76
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
77
|
+
copy of this software and associated documentation files (the "Software"),
|
|
78
|
+
to deal in the Software without restriction, including without limitation
|
|
79
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
80
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
81
|
+
Software is furnished to do so, subject to the following conditions:
|
|
82
|
+
|
|
83
|
+
The above copyright notice and this permission notice shall be included in
|
|
84
|
+
all copies or substantial portions of the Software.
|
|
85
|
+
|
|
86
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
87
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
88
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
89
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
90
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
92
|
+
DEALINGS IN THE SOFTWARE.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Apache License, Version 2.0
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
Apache License
|
|
99
|
+
Version 2.0, January 2004
|
|
100
|
+
http://www.apache.org/licenses/
|
|
101
|
+
|
|
102
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
103
|
+
|
|
104
|
+
1. Definitions.
|
|
105
|
+
|
|
106
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
107
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
108
|
+
|
|
109
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
110
|
+
the copyright owner that is granting the License.
|
|
111
|
+
|
|
112
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
113
|
+
other entities that control, are controlled by, or are under common
|
|
114
|
+
control with that entity. For the purposes of this definition,
|
|
115
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
116
|
+
direction or management of such entity, whether by contract or
|
|
117
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
118
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
119
|
+
|
|
120
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
121
|
+
exercising permissions granted by this License.
|
|
122
|
+
|
|
123
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
124
|
+
including but not limited to software source code, documentation
|
|
125
|
+
source, and configuration files.
|
|
126
|
+
|
|
127
|
+
"Object" form shall mean any form resulting from mechanical
|
|
128
|
+
transformation or translation of a Source form, including but
|
|
129
|
+
not limited to compiled object code, generated documentation,
|
|
130
|
+
and conversions to other media types.
|
|
131
|
+
|
|
132
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
133
|
+
Object form, made available under the License, as indicated by a
|
|
134
|
+
copyright notice that is included in or attached to the work
|
|
135
|
+
(an example is provided in the Appendix below).
|
|
136
|
+
|
|
137
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
138
|
+
form, that is based on (or derived from) the Work and for which the
|
|
139
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
140
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
141
|
+
of this License, Derivative Works shall not include works that remain
|
|
142
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
143
|
+
the Work and Derivative Works thereof.
|
|
144
|
+
|
|
145
|
+
"Contribution" shall mean any work of authorship, including
|
|
146
|
+
the original version of the Work and any modifications or additions
|
|
147
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
148
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
149
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
150
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
151
|
+
means any form of electronic, verbal, or written communication sent
|
|
152
|
+
to the Licensor or its representatives, including but not limited to
|
|
153
|
+
communication on electronic mailing lists, source code control systems,
|
|
154
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
155
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
156
|
+
excluding communication that is conspicuously marked or otherwise
|
|
157
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
158
|
+
|
|
159
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
160
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
161
|
+
subsequently incorporated within the Work.
|
|
162
|
+
|
|
163
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
164
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
165
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
166
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
167
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
168
|
+
Work and such Derivative Works in Source or Object form.
|
|
169
|
+
|
|
170
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
171
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
172
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
173
|
+
(except as stated in this section) patent license to make, have made,
|
|
174
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
175
|
+
where such license applies only to those patent claims licensable
|
|
176
|
+
by such Contributor that are necessarily infringed by their
|
|
177
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
178
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
179
|
+
institute patent litigation against any entity (including a
|
|
180
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
181
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
182
|
+
or contributory patent infringement, then any patent licenses
|
|
183
|
+
granted to You under this License for that Work shall terminate
|
|
184
|
+
as of the date such litigation is filed.
|
|
185
|
+
|
|
186
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
187
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
188
|
+
modifications, and in Source or Object form, provided that You
|
|
189
|
+
meet the following conditions:
|
|
190
|
+
|
|
191
|
+
(a) You must give any other recipients of the Work or
|
|
192
|
+
Derivative Works a copy of this License; and
|
|
193
|
+
|
|
194
|
+
(b) You must cause any modified files to carry prominent notices
|
|
195
|
+
stating that You changed the files; and
|
|
196
|
+
|
|
197
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
198
|
+
that You distribute, all copyright, patent, trademark, and
|
|
199
|
+
attribution notices from the Source form of the Work,
|
|
200
|
+
excluding those notices that do not pertain to any part of
|
|
201
|
+
the Derivative Works; and
|
|
202
|
+
|
|
203
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
204
|
+
distribution, then any Derivative Works that You distribute must
|
|
205
|
+
include a readable copy of the attribution notices contained
|
|
206
|
+
within such NOTICE file, excluding those notices that do not
|
|
207
|
+
pertain to any part of the Derivative Works, in at least one
|
|
208
|
+
of the following places: within a NOTICE text file distributed
|
|
209
|
+
as part of the Derivative Works; within the Source form or
|
|
210
|
+
documentation, if provided along with the Derivative Works; or,
|
|
211
|
+
within a display generated by the Derivative Works, if and
|
|
212
|
+
wherever such third-party notices normally appear. The contents
|
|
213
|
+
of the NOTICE file are for informational purposes only and
|
|
214
|
+
do not modify the License. You may add Your own attribution
|
|
215
|
+
notices within Derivative Works that You distribute, alongside
|
|
216
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
217
|
+
that such additional attribution notices cannot be construed
|
|
218
|
+
as modifying the License.
|
|
219
|
+
|
|
220
|
+
You may add Your own copyright statement to Your modifications and
|
|
221
|
+
may provide additional or different license terms and conditions
|
|
222
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
223
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
224
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
225
|
+
the conditions stated in this License.
|
|
226
|
+
|
|
227
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
228
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
229
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
230
|
+
this License, without any additional terms or conditions.
|
|
231
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
232
|
+
the terms of any separate license agreement you may have executed
|
|
233
|
+
with Licensor regarding such Contributions.
|
|
234
|
+
|
|
235
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
236
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
237
|
+
except as required for reasonable and customary use in describing the
|
|
238
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
239
|
+
|
|
240
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
241
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
242
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
243
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
244
|
+
implied, including, without limitation, any warranties or conditions
|
|
245
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
246
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
247
|
+
appropriateness of using or redistributing the Work and assume any
|
|
248
|
+
risks associated with Your exercise of permissions under this License.
|
|
249
|
+
|
|
250
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
251
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
252
|
+
unless required by applicable law (such as deliberate and grossly
|
|
253
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
254
|
+
liable to You for damages, including any direct, indirect, special,
|
|
255
|
+
incidental, or consequential damages of any character arising as a
|
|
256
|
+
result of this License or out of the use or inability to use the
|
|
257
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
258
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
259
|
+
other commercial damages or losses), even if such Contributor
|
|
260
|
+
has been advised of the possibility of such damages.
|
|
261
|
+
|
|
262
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
263
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
264
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
265
|
+
or other liability obligations and/or rights consistent with this
|
|
266
|
+
License. However, in accepting such obligations, You may act only
|
|
267
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
268
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
269
|
+
defend, and hold each Contributor harmless for any liability
|
|
270
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
271
|
+
of your accepting any such warranty or additional liability.
|
|
272
|
+
|
|
273
|
+
END OF TERMS AND CONDITIONS
|
|
274
|
+
|
|
275
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
276
|
+
|
|
277
|
+
To apply the Apache License to your work, attach the following
|
|
278
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
279
|
+
replaced with your own identifying information. (Don't include
|
|
280
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
281
|
+
comment syntax for the file format. We also recommend that a
|
|
282
|
+
file or class name and description of purpose be included on the
|
|
283
|
+
same "printed page" as the copyright notice for easier
|
|
284
|
+
identification within third-party archives.
|
|
285
|
+
|
|
286
|
+
Copyright {yyyy} {name of copyright owner}
|
|
287
|
+
|
|
288
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
289
|
+
you may not use this file except in compliance with the License.
|
|
290
|
+
You may obtain a copy of the License at
|
|
291
|
+
|
|
292
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
293
|
+
|
|
294
|
+
Unless required by applicable law or agreed to in writing, software
|
|
295
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
296
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
297
|
+
See the License for the specific language governing permissions and
|
|
298
|
+
limitations under the License.
|
|
299
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Gzip } from 'node:zlib';
|
|
2
|
+
export type BuildContextOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* The directory of the context
|
|
5
|
+
*/
|
|
6
|
+
directory: string;
|
|
7
|
+
/**
|
|
8
|
+
* The files and the directories packed (their paths relative to the directory): the directories are packed with
|
|
9
|
+
* their content
|
|
10
|
+
*/
|
|
11
|
+
entries: string[];
|
|
12
|
+
/**
|
|
13
|
+
* The files packed even when .dockerignore excludes them (the Dockerfile, as the docker command does)
|
|
14
|
+
*/
|
|
15
|
+
always?: string[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Pack the context of a build: a gzipped tar stream; the files excluded by the .dockerignore of the directory are
|
|
19
|
+
* skipped. An error of the packing (a file which cannot be read, or changes while it is read) is an error of the stream
|
|
20
|
+
* @param options
|
|
21
|
+
*/
|
|
22
|
+
export declare function packBuildContext(options: BuildContextOptions): Gzip;
|