@otterdeploy/docker 0.1.1 → 0.3.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/README.md +31 -20
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +6 -3013
- package/package.json +5 -3
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -16,12 +16,15 @@ import { Docker } from "@otterdeploy/docker";
|
|
|
16
16
|
// Auto-detect from DOCKER_HOST, DOCKER_TLS_VERIFY, etc.
|
|
17
17
|
const docker = Docker.fromEnv();
|
|
18
18
|
|
|
19
|
-
// List containers
|
|
19
|
+
// List containers (check result)
|
|
20
20
|
const result = await docker.containers.list({ all: true });
|
|
21
21
|
if (result.isOk()) {
|
|
22
22
|
console.log(result.value);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// Or unwrap directly (throws on error)
|
|
26
|
+
const containers = (await docker.containers.list({ all: true })).unwrap();
|
|
27
|
+
|
|
25
28
|
// Pull an image
|
|
26
29
|
const stream = await docker.pull("nginx:latest");
|
|
27
30
|
|
|
@@ -41,14 +44,14 @@ Transports connect to the Docker daemon over different protocols.
|
|
|
41
44
|
const docker = Docker.fromEnv();
|
|
42
45
|
```
|
|
43
46
|
|
|
44
|
-
Reads `DOCKER_HOST`, `DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, and `DOCKER_CLIENT_TIMEOUT`.
|
|
47
|
+
Reads `DOCKER_HOST`, `DOCKER_TLS_VERIFY`, `DOCKER_CERT_PATH`, and `DOCKER_CLIENT_TIMEOUT`. Defaults to API version `v1.47`.
|
|
45
48
|
|
|
46
49
|
### Unix Socket (default)
|
|
47
50
|
|
|
48
51
|
```ts
|
|
49
52
|
const docker = new Docker({
|
|
50
53
|
transport: { type: "unix", socketPath: "/var/run/docker.sock" },
|
|
51
|
-
apiVersion: "v1.
|
|
54
|
+
apiVersion: "v1.47",
|
|
52
55
|
});
|
|
53
56
|
```
|
|
54
57
|
|
|
@@ -66,7 +69,7 @@ const docker = new Docker({
|
|
|
66
69
|
key: fs.readFileSync("/certs/key.pem"),
|
|
67
70
|
},
|
|
68
71
|
},
|
|
69
|
-
apiVersion: "v1.
|
|
72
|
+
apiVersion: "v1.47",
|
|
70
73
|
});
|
|
71
74
|
```
|
|
72
75
|
|
|
@@ -81,22 +84,24 @@ const docker = new Docker({
|
|
|
81
84
|
username: "deploy",
|
|
82
85
|
privateKey: fs.readFileSync("~/.ssh/id_rsa", "utf8"),
|
|
83
86
|
},
|
|
84
|
-
apiVersion: "v1.
|
|
87
|
+
apiVersion: "v1.47",
|
|
85
88
|
});
|
|
86
89
|
```
|
|
87
90
|
|
|
91
|
+
> **Note:** SSH transport does not support interactive `exec` or `attach` operations (i.e., `dialHijack`). These require a direct connection upgrade that is not possible over SSH tunnels. Use Unix socket or TCP transport for interactive container sessions.
|
|
92
|
+
|
|
88
93
|
### Windows Named Pipes
|
|
89
94
|
|
|
90
95
|
```ts
|
|
91
96
|
const docker = new Docker({
|
|
92
97
|
transport: { type: "npipe", path: "//./pipe/docker_engine" },
|
|
93
|
-
apiVersion: "v1.
|
|
98
|
+
apiVersion: "v1.47",
|
|
94
99
|
});
|
|
95
100
|
```
|
|
96
101
|
|
|
97
102
|
## API Reference
|
|
98
103
|
|
|
99
|
-
All methods return `Result<T, DockerError>` from [better-result](https://github.com/niconiahi/better-result). Use `isOk()` / `isErr()` for type-safe error handling.
|
|
104
|
+
All methods return `Result<T, DockerError>` from [better-result](https://github.com/niconiahi/better-result). Use `isOk()` / `isErr()` for type-safe error handling, or `.unwrap()` to get the value directly (throws on error).
|
|
100
105
|
|
|
101
106
|
### Containers
|
|
102
107
|
|
|
@@ -224,8 +229,18 @@ await docker.system.pruneBuilder({ all: true });
|
|
|
224
229
|
```ts
|
|
225
230
|
// Services
|
|
226
231
|
const services = await docker.services.list();
|
|
227
|
-
const service = await docker.services.create({
|
|
228
|
-
|
|
232
|
+
const service = await docker.services.create({
|
|
233
|
+
Name: "web",
|
|
234
|
+
TaskTemplate: {
|
|
235
|
+
/* ... */
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
await service.update({
|
|
239
|
+
version: 1,
|
|
240
|
+
spec: {
|
|
241
|
+
/* ... */
|
|
242
|
+
},
|
|
243
|
+
});
|
|
229
244
|
await service.logs({ stdout: true });
|
|
230
245
|
await service.remove();
|
|
231
246
|
|
|
@@ -294,6 +309,12 @@ if (result.isErr()) {
|
|
|
294
309
|
}
|
|
295
310
|
```
|
|
296
311
|
|
|
312
|
+
If you prefer exceptions, use `.unwrap()` to get the value directly or throw on error:
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
const info = (await container.inspect()).unwrap(); // throws DockerError on failure
|
|
316
|
+
```
|
|
317
|
+
|
|
297
318
|
Error types: `DockerBadRequestError`, `DockerUnauthorizedError`, `DockerForbiddenError`, `DockerNotFoundError`, `DockerConflictError`, `DockerServerError`, `DockerServiceUnavailableError`, `DockerNetworkError`, `DockerTimeoutError`, `DockerAbortError`.
|
|
298
319
|
|
|
299
320
|
## BuildKit Sessions
|
|
@@ -303,22 +324,12 @@ For BuildKit v2 builds with registry authentication:
|
|
|
303
324
|
```ts
|
|
304
325
|
import { withSession } from "@otterdeploy/docker";
|
|
305
326
|
|
|
306
|
-
const session = await withSession(transport, "v1.
|
|
327
|
+
const session = await withSession(transport, "v1.47", {
|
|
307
328
|
username: "user",
|
|
308
329
|
password: "pass",
|
|
309
330
|
});
|
|
310
331
|
```
|
|
311
332
|
|
|
312
|
-
## Scripts
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
bun run build # Build with tsdown
|
|
316
|
-
bun test # Run tests
|
|
317
|
-
bun run lint # Lint with oxlint
|
|
318
|
-
bun run format # Format with oxfmt
|
|
319
|
-
bun run typecheck # Type check
|
|
320
|
-
```
|
|
321
|
-
|
|
322
333
|
## License
|
|
323
334
|
|
|
324
335
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -2007,5 +2007,4 @@ type SessionResult = {
|
|
|
2007
2007
|
*/
|
|
2008
2008
|
declare function withSession(transport: Transport, apiVersion: string, auth?: AuthConfig): Promise<Result<SessionResult, DockerError>>;
|
|
2009
2009
|
//#endregion
|
|
2010
|
-
export { type ArchiveInfo, type AuthConfig, type AuthResponse, type BuildOptions, type BuilderPruneOptions, type BuilderPruneResponse, type CheckpointCreateOptions, type Config, type ConfigCreateOptions, ConfigEntity, type ConfigListOptions, ConfigOperations, type ConfigSpec, type ConfigUpdateOptions, Container, type ContainerArchiveOptions, type ContainerAttachOptions, type ContainerChange, type ContainerCommitOptions, type ContainerConfig, type ContainerInspect, type ContainerKillOptions, type ContainerListOptions, ContainerOperations, type ContainerPruneOptions, type ContainerRemoveOptions, type ContainerResizeOptions, type ContainerRestartOptions, type ContainerState, type ContainerStats, type ContainerStatsOptions, type ContainerStopOptions, type ContainerSummary, type ContainerTopResponse, type ContainerUpdateOptions, type ContainerUpdateResponse, type ContainerWaitOptions, type CreateContainerOptions, type CreateContainerResponse, type CreateImageOptions, type CreateVolumeOptions, type DialOptions, type DialResponse, Docker, DockerAbortError, type DockerApiError, DockerBadRequestError, type DockerConfig, DockerConflictError, DockerDecodeError, type DockerError, DockerForbiddenError, type DockerInfo, DockerNetworkError, DockerNotFoundError, DockerServerError, DockerServiceUnavailableError, DockerStream, DockerTimeoutError, type DockerTransportError, DockerUnauthorizedError, DockerUnknownError, type DockerVersion, type EndpointIPAMConfig, type EndpointPortConfig, type EndpointSettings, type EndpointSpec, type EventActor, type EventMessage, type EventsOptions, Exec, type ExecCreateOptions, type ExecInspect, type ExecStartOptions, type ExecStartWithStdinOptions, type Filters, type HealthConfig, type HostConfig, HttpDuplex, type HttpMethod, type IPAM, type IdResponse, Image, type ImageConfig, type ImageDeleteResponseItem, type ImageHistory, type ImageImportOptions, type ImageInspect, type ImageListOptions, ImageOperations, type ImagePruneOptions, type ImagePushOptions, type ImageRemoveOptions, type ImageSearchOptions, type ImageSummary, type ImageTagOptions, type LogsOptions, type Mount, type MountPoint, NamedPipeTransport, type Network, type NetworkConnectOptions, type NetworkCreateOptions, type NetworkCreateResponse, type NetworkDisconnectOptions, NetworkEntity, type NetworkListOptions, NetworkOperations, type NetworkPruneOptions, type NetworkSettings, type NetworkingConfig, type Node, NodeEntity, type NodeListOptions, NodeOperations, type NodeRemoveOptions, type NodeSpec, type NodeUpdateOptions, type ObjectVersion, type Plugin, type PluginConfigureOptions, type PluginCreateOptions, type PluginDisableOptions, type PluginEnableOptions, PluginEntity, type PluginInstallOptions, type PluginListOptions, PluginOperations, type PluginPrivilege, type PluginPrivilegesOptions, type PluginRemoveOptions, type PluginUpgradeOptions, type Port, type PortBinding, type PruneResponse, type PullOptions, type RestartPolicy, type RunOptions, type RunResult, type SearchResult, type Secret, type SecretCreateOptions, SecretEntity, type SecretListOptions, SecretOperations, type SecretSpec, type SecretUpdateOptions, type Service, type ServiceCreateOptions, type ServiceCreateResponse, ServiceEntity, type ServiceListOptions, ServiceOperations, type ServiceSpec, type ServiceUpdateConfig, type ServiceUpdateOptions, type ServiceUpdateResponse, type SessionResult, type StatusCodeMap, type SwarmInitOptions, type SwarmJoinOptions, type SwarmLeaveOptions, type SwarmUpdateOptions, type SystemDf, SystemOperations, type Task, TaskEntity, type TaskListOptions, TaskOperations, type TlsConfig, type Transport, type TransportConfig, type Volume, VolumeEntity, type VolumeListOptions, type VolumeListResponse, VolumeOperations, type VolumePruneOptions, type VolumeRemoveOptions, type WaitResponse, createTransport, createTransportFromEnv, demuxStream, followProgress, statusCodeToError, withSession };
|
|
2011
|
-
//# sourceMappingURL=index.d.mts.map
|
|
2010
|
+
export { type ArchiveInfo, type AuthConfig, type AuthResponse, type BuildOptions, type BuilderPruneOptions, type BuilderPruneResponse, type CheckpointCreateOptions, type Config, type ConfigCreateOptions, ConfigEntity, type ConfigListOptions, ConfigOperations, type ConfigSpec, type ConfigUpdateOptions, Container, type ContainerArchiveOptions, type ContainerAttachOptions, type ContainerChange, type ContainerCommitOptions, type ContainerConfig, type ContainerInspect, type ContainerKillOptions, type ContainerListOptions, ContainerOperations, type ContainerPruneOptions, type ContainerRemoveOptions, type ContainerResizeOptions, type ContainerRestartOptions, type ContainerState, type ContainerStats, type ContainerStatsOptions, type ContainerStopOptions, type ContainerSummary, type ContainerTopResponse, type ContainerUpdateOptions, type ContainerUpdateResponse, type ContainerWaitOptions, type CreateContainerOptions, type CreateContainerResponse, type CreateImageOptions, type CreateVolumeOptions, type DialOptions, type DialResponse, Docker, DockerAbortError, type DockerApiError, DockerBadRequestError, type DockerConfig, DockerConflictError, DockerDecodeError, type DockerError, DockerForbiddenError, type DockerInfo, DockerNetworkError, DockerNotFoundError, DockerServerError, DockerServiceUnavailableError, DockerStream, DockerTimeoutError, type DockerTransportError, DockerUnauthorizedError, DockerUnknownError, type DockerVersion, type EndpointIPAMConfig, type EndpointPortConfig, type EndpointSettings, type EndpointSpec, type EventActor, type EventMessage, type EventsOptions, Exec, type ExecCreateOptions, type ExecInspect, type ExecStartOptions, type ExecStartWithStdinOptions, type Filters, type HealthConfig, type HostConfig, HttpDuplex, type HttpMethod, type IPAM, type IdResponse, Image, type ImageConfig, type ImageDeleteResponseItem, type ImageHistory, type ImageImportOptions, type ImageInspect, type ImageListOptions, ImageOperations, type ImagePruneOptions, type ImagePushOptions, type ImageRemoveOptions, type ImageSearchOptions, type ImageSummary, type ImageTagOptions, type LogsOptions, type Mount, type MountPoint, NamedPipeTransport, type Network, type NetworkConnectOptions, type NetworkCreateOptions, type NetworkCreateResponse, type NetworkDisconnectOptions, NetworkEntity, type NetworkListOptions, NetworkOperations, type NetworkPruneOptions, type NetworkSettings, type NetworkingConfig, type Node, NodeEntity, type NodeListOptions, NodeOperations, type NodeRemoveOptions, type NodeSpec, type NodeUpdateOptions, type ObjectVersion, type Plugin, type PluginConfigureOptions, type PluginCreateOptions, type PluginDisableOptions, type PluginEnableOptions, PluginEntity, type PluginInstallOptions, type PluginListOptions, PluginOperations, type PluginPrivilege, type PluginPrivilegesOptions, type PluginRemoveOptions, type PluginUpgradeOptions, type Port, type PortBinding, type PruneResponse, type PullOptions, type RestartPolicy, type RunOptions, type RunResult, type SearchResult, type Secret, type SecretCreateOptions, SecretEntity, type SecretListOptions, SecretOperations, type SecretSpec, type SecretUpdateOptions, type Service, type ServiceCreateOptions, type ServiceCreateResponse, ServiceEntity, type ServiceListOptions, ServiceOperations, type ServiceSpec, type ServiceUpdateConfig, type ServiceUpdateOptions, type ServiceUpdateResponse, type SessionResult, type StatusCodeMap, type SwarmInitOptions, type SwarmJoinOptions, type SwarmLeaveOptions, type SwarmUpdateOptions, type SystemDf, SystemOperations, type Task, TaskEntity, type TaskListOptions, TaskOperations, type TlsConfig, type Transport, type TransportConfig, type Volume, VolumeEntity, type VolumeListOptions, type VolumeListResponse, VolumeOperations, type VolumePruneOptions, type VolumeRemoveOptions, type WaitResponse, createTransport, createTransportFromEnv, demuxStream, followProgress, statusCodeToError, withSession };
|