presidium 1.0.4 → 1.0.5
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/Docker.js +131 -31
- package/package.json +1 -1
package/Docker.js
CHANGED
|
@@ -70,6 +70,8 @@ class Docker {
|
|
|
70
70
|
* * `IdentityToken` - a token used to authenticate the user in place of a username and password.
|
|
71
71
|
*
|
|
72
72
|
* ```javascript
|
|
73
|
+
* const docker = new Docker()
|
|
74
|
+
*
|
|
73
75
|
* const data = await docker.auth({
|
|
74
76
|
* username: 'admin',
|
|
75
77
|
* password: 'password',
|
|
@@ -121,19 +123,22 @@ class Docker {
|
|
|
121
123
|
* * (none)
|
|
122
124
|
*
|
|
123
125
|
* Return:
|
|
124
|
-
* * `
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
126
|
+
* * `data`
|
|
127
|
+
* * `Id` - the image ID.
|
|
128
|
+
* * `ParentId` - ID of the parent image.
|
|
129
|
+
* * `RepoTags` - list of image names and tags in the local image cache that reference the image.
|
|
130
|
+
* * `RepoDigests` - list of content-addressable digests of locally available image manifests that the image is referenced from.
|
|
131
|
+
* * `Created` - the date and time at which the image was created as seconds since EPOCH (January 1, 1970 at midnight UTC/GMT).
|
|
132
|
+
* * `Size` - the total size in bytes of the image including all layers that the image is composed of.
|
|
133
|
+
* * `SharedSize` - total size of image layers that are shared between the image and other images. `-1` indicates that this value has not been calculated.
|
|
134
|
+
* * `Labels` - object of user-defined key/value metadata.
|
|
135
|
+
* * `Containers` - number of containers using this image. Includes both stopped and running containers. `-1` indicates that this value has not been calculated.
|
|
136
|
+
* * `Manifests` - list of [image manifests](https://docs.docker.com/reference/cli/docker/manifest/) available in the image. Warning: `Manifests` is experimental and may change at any time without any backward compatibility.
|
|
137
|
+
* * `Descriptor` - an object containing digest, media type, and size for the image, as defined in the [OCI Content Descriptors Specification](https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md).
|
|
135
138
|
*
|
|
136
139
|
* ```javascript
|
|
140
|
+
* const docker = new Docker()
|
|
141
|
+
*
|
|
137
142
|
* const data = await docker.listImages()
|
|
138
143
|
* ```
|
|
139
144
|
*/
|
|
@@ -191,7 +196,7 @@ class Docker {
|
|
|
191
196
|
* * `ImageID` - the ID of the image used to create the container.
|
|
192
197
|
* * `ImageManifestDescriptor` - an object containing digest, media type, and size for the image used to create the container, as defined in the [OCI Content Descriptors Specification](https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md).
|
|
193
198
|
* * `Command` - the command to run when starting the container.
|
|
194
|
-
* * `Created` - date and time at which the image was created as seconds since EPOCH (January 1, 1970 at midnight UTC/GMT).
|
|
199
|
+
* * `Created` - the date and time at which the image was created as seconds since EPOCH (January 1, 1970 at midnight UTC/GMT).
|
|
195
200
|
* * `Ports` - port-mappings for the container.
|
|
196
201
|
* * `SizeRw` - the size of files that have been created or changed by the container.
|
|
197
202
|
* * `SizeRootFs` - the total size of all files in the read-only layers of the image that are used by the container.
|
|
@@ -232,7 +237,7 @@ class Docker {
|
|
|
232
237
|
* ) -> dataStream Promise<stream.Readable>
|
|
233
238
|
* ```
|
|
234
239
|
*
|
|
235
|
-
* Pulls a Docker image to the server.
|
|
240
|
+
* Pulls or imports a Docker image to the server.
|
|
236
241
|
*
|
|
237
242
|
* Arguments:
|
|
238
243
|
* * `name` - name of the image to pull. May include a tag or digest.
|
|
@@ -251,6 +256,8 @@ class Docker {
|
|
|
251
256
|
* * `dataStream` - a readable stream of the progress of the Docker `pullImage` operation.
|
|
252
257
|
*
|
|
253
258
|
* ```javascript
|
|
259
|
+
* const docker = new Docker()
|
|
260
|
+
*
|
|
254
261
|
* const pullStream = await docker.pullImage('nginx:1.19')
|
|
255
262
|
*
|
|
256
263
|
* pullStream.pipe(process.stdout)
|
|
@@ -509,7 +516,36 @@ class Docker {
|
|
|
509
516
|
* }>
|
|
510
517
|
* ```
|
|
511
518
|
*
|
|
519
|
+
* Returns low-level information about a Docker image.
|
|
520
|
+
*
|
|
512
521
|
* Arguments:
|
|
522
|
+
* * `image` - the name or ID of the image to inspect
|
|
523
|
+
*
|
|
524
|
+
* Return:
|
|
525
|
+
* * `data`
|
|
526
|
+
* * `Id` - the content-addressable ID of an image.
|
|
527
|
+
* * `Descriptor` - an object containing digest, media type, and size for the image, as defined in the [OCI Content Descriptors Specification](https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md).
|
|
528
|
+
* * `Manifests` - list of [image manifests](https://docs.docker.com/reference/cli/docker/manifest/) available in the image. Warning: `Manifests` is experimental and may change at any time without any backward compatibility.
|
|
529
|
+
* * `RepoTags` - list of image names and tags in the local image cache that reference the image.
|
|
530
|
+
* * `RepoDigests` - list of content-addressable digests of locally available image manifests that the image is referenced from.
|
|
531
|
+
* * `Comment` - optional message that was set when committing or importing the image.
|
|
532
|
+
* * `Created` - the date and time at which the image was created as seconds since EPOCH (January 1, 1970 at midnight UTC/GMT).
|
|
533
|
+
* * `Author` - the name of the author that was specified when committing the image.
|
|
534
|
+
* * `Config` - the configuration of the image. `Config` fields are used as defaults when starting a container from an image.
|
|
535
|
+
* * `Architecture` - the CPU architecture that the image runs on.
|
|
536
|
+
* * `Variant` - a CPU architecture variant.
|
|
537
|
+
* * `Os` - the operating system that the image is built to run on.
|
|
538
|
+
* * `OsVersion` - the version of the operating system that the image is built to run on.
|
|
539
|
+
* * `Size` - the total size in bytes of the image including all layers that the image is composed of.
|
|
540
|
+
* * `GraphDriver` - information about the storage driver that stores the filesystem used by the container and the image.
|
|
541
|
+
* * `RootFS` - information about the image's RootFS, including the layer IDs.
|
|
542
|
+
* * `Metadata` - additional metadata of the image in the local cache. This information is not part of the image itself.
|
|
543
|
+
*
|
|
544
|
+
* ```javascript
|
|
545
|
+
* const docker = new Docker()
|
|
546
|
+
*
|
|
547
|
+
* const data = await docker.inspectImage('my-image:example')
|
|
548
|
+
* ```
|
|
513
549
|
*/
|
|
514
550
|
async inspectImage(image) {
|
|
515
551
|
const response = await this.http.get(`/images/${image}/json`)
|
|
@@ -523,12 +559,26 @@ class Docker {
|
|
|
523
559
|
* @docs
|
|
524
560
|
* ```coffeescript [specscript]
|
|
525
561
|
* tagImage(
|
|
526
|
-
* sourceImageTag string, # '<image>:<tag>'
|
|
527
|
-
* targetImageTag string, # '<image>:<tag>'
|
|
562
|
+
* sourceImageTag string, # '[<repo>/]<image>:<tag>'
|
|
563
|
+
* targetImageTag string, # '[<repo>/]<image>:<tag>'
|
|
528
564
|
* ) -> data Promise<{}>
|
|
529
565
|
* ```
|
|
566
|
+
*
|
|
567
|
+
* Creates a Docker image tag that refers to a source Docker image tag.
|
|
568
|
+
*
|
|
569
|
+
* Arguments:
|
|
570
|
+
* * `sourceImageTag` - the source Docker image tag
|
|
571
|
+
* * `targetImageTag` - the Docker image tag to create
|
|
572
|
+
*
|
|
573
|
+
* Return:
|
|
574
|
+
* * `data` - empty object.
|
|
575
|
+
*
|
|
576
|
+
* ```javascript
|
|
577
|
+
* const docker = new Docker()
|
|
578
|
+
*
|
|
579
|
+
* await docker.tagImage('my-image:example', 'my-registry/my-image:example')
|
|
580
|
+
* ```
|
|
530
581
|
*/
|
|
531
|
-
// async tagImage(image, options = {}) {
|
|
532
582
|
async tagImage(sourceImageTag, targetImageTag) {
|
|
533
583
|
const targetImageTagParts = targetImageTag.split(':')
|
|
534
584
|
const tag = targetImageTagParts[targetImageTagParts.length - 1]
|
|
@@ -547,11 +597,28 @@ class Docker {
|
|
|
547
597
|
* ```coffeescript [specscript]
|
|
548
598
|
* removeImage(image string, options? {
|
|
549
599
|
* force: boolean,
|
|
550
|
-
* noprune: boolean,
|
|
600
|
+
* noprune: boolean,
|
|
551
601
|
* }) -> data Promise<Array<{ Untagged: string }|{ Deleted: string }>>
|
|
552
602
|
* ```
|
|
553
603
|
*
|
|
554
|
-
*
|
|
604
|
+
* Removes a Docker image and any untagged parent images that were referenced by the Docker image from the server. Docker images can't be removed if they have descendant images, are being used by a running container, or are being used by a build.
|
|
605
|
+
*
|
|
606
|
+
* Arguments:
|
|
607
|
+
* * `image` - the name or ID of the image to remove.
|
|
608
|
+
* * `options`
|
|
609
|
+
* * `force` - if `true`, removes the image even if it is being used by stopped containers or has other tags. If `false`, the operation will error if the image is being used by stopped containers. Defaults to `false`.
|
|
610
|
+
* * `noprune` - if `true`, the operation will not delete untagged parent images. If `false`, the operation will delete untagged parent images. Defaults to `false`.
|
|
611
|
+
*
|
|
612
|
+
* Return:
|
|
613
|
+
* * `data`
|
|
614
|
+
* * `Untagged` - the image ID of an image that was untagged.
|
|
615
|
+
* * `Deleted` - the image ID of an image that was deleted.
|
|
616
|
+
*
|
|
617
|
+
* ```javascript
|
|
618
|
+
* const docker = new Docker()
|
|
619
|
+
*
|
|
620
|
+
* await docker.removeImage('my-image:example')
|
|
621
|
+
* ```
|
|
555
622
|
*/
|
|
556
623
|
async removeImage(image, options = {}) {
|
|
557
624
|
const response = await this.http.delete(`/images/${image}?${
|
|
@@ -569,18 +636,21 @@ class Docker {
|
|
|
569
636
|
* ```coffeescript [specscript]
|
|
570
637
|
* createContainer(options {
|
|
571
638
|
* name: string,
|
|
572
|
-
* image: string,
|
|
573
|
-
* rm: boolean,
|
|
639
|
+
* image: string,
|
|
640
|
+
* rm: boolean,
|
|
574
641
|
* restart: 'no'|'on-failure[:<max-retries>]'|'always'|'unless-stopped',
|
|
575
|
-
* logDriver: 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk'|'none',
|
|
642
|
+
* logDriver: 'local'|'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk'|'etwlogs'|'none',
|
|
576
643
|
* logDriverOptions: Object<string>,
|
|
577
|
-
* publish:
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
644
|
+
* publish: Object<
|
|
645
|
+
* [hostPort string]: containerPort string # 8080
|
|
646
|
+
* |containerPortWithProtocol string # '<containerPort>[/"tcp"|"udp"|"sctp"]'
|
|
647
|
+
* >,
|
|
648
|
+
* healthCmd: Array<string>,
|
|
649
|
+
* healthInterval: 10e9|number, # nanoseconds, minimum 1e6
|
|
650
|
+
* healthTimeout: 20e9|number, # nanoseconds, minimum 1e6
|
|
651
|
+
* healthRetries: 5|number,
|
|
652
|
+
* healthStartPeriod: number, # nanoseconds, minimum 1e6
|
|
653
|
+
* memory: number, # bytes
|
|
584
654
|
* cpus: number, // number of cpus
|
|
585
655
|
* gpus?: 'all', // expose gpus
|
|
586
656
|
* mounts: Array<{
|
|
@@ -607,6 +677,25 @@ class Docker {
|
|
|
607
677
|
* }>
|
|
608
678
|
* ```
|
|
609
679
|
*
|
|
680
|
+
* Creates a Docker container.
|
|
681
|
+
*
|
|
682
|
+
* Arguments:
|
|
683
|
+
* * `options`
|
|
684
|
+
* * `name` - the name that will be assigned to the container.
|
|
685
|
+
* * `image` - the name and tag of the image.
|
|
686
|
+
* * `rm` - automatically remove the container when it exits.
|
|
687
|
+
* * `restart` - the restart policy for the container.
|
|
688
|
+
* * `logDriver` - the logging driver used for the container.
|
|
689
|
+
* * `logDriverOptions` - driver-specific configuration options for the logging driver.
|
|
690
|
+
* * `publish` - object of mappings of host ports to container ports.
|
|
691
|
+
* * `healthCmd` - a command that checks the health of the container. The health check fails if the command errors. The command is run inside the container.
|
|
692
|
+
* * `healthInterval` - time in nanoseconds to wait between healthchecks.
|
|
693
|
+
* * `healthTimeout` - time in nanoseconds to wait before the healthcheck fails.
|
|
694
|
+
* * `healthRetries` - number of times to retry the health check before the container is considered unhealhty.
|
|
695
|
+
* * `healthStartPeriod` - time in nanoseconds to wait when the container starts up before running the first health check command.
|
|
696
|
+
* * `memory` - memory limit of the container in bytes.
|
|
697
|
+
* * `cpus` - number of CPUs
|
|
698
|
+
*
|
|
610
699
|
* Restart policies:
|
|
611
700
|
* * `no` - do not restart the container when it exits
|
|
612
701
|
* * `on-failure` - restart only if container exits with non-zero exit code
|
|
@@ -693,6 +782,8 @@ class Docker {
|
|
|
693
782
|
},
|
|
694
783
|
|
|
695
784
|
...options.memory && { Memory: options.memory },
|
|
785
|
+
...options.cpus && { NanoCpus: options.cpus * 1e9 },
|
|
786
|
+
|
|
696
787
|
...options.publish && {
|
|
697
788
|
PortBindings: map.entries(all([ // publish and PortBindings are reversed
|
|
698
789
|
pipe([ // container port
|
|
@@ -775,7 +866,10 @@ class Docker {
|
|
|
775
866
|
* restart: 'no'|'on-failure[:<max-retries>]'|'always'|'unless-stopped',
|
|
776
867
|
* logDriver: 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk'|'none',
|
|
777
868
|
* logDriverOptions: Object<string>,
|
|
778
|
-
* publish:
|
|
869
|
+
* publish: Object<
|
|
870
|
+
* [hostPort string]: containerPort string # 8080
|
|
871
|
+
* |containerPortWithProtocol string # '<containerPort>[/"tcp"|"udp"|"sctp"]'
|
|
872
|
+
* >,
|
|
779
873
|
* healthCmd: Array<string>, // healthcheck command. See description
|
|
780
874
|
* healthInterval: 10e9|>1e6, // nanoseconds to wait between healthchecks; 0 means inherit
|
|
781
875
|
* healthTimeout: 20e9|>1e6, // nanoseconds to wait before healthcheck fails
|
|
@@ -1050,7 +1144,10 @@ class Docker {
|
|
|
1050
1144
|
* restartDelay: 10e9|number, // nanoseconds to delay between restarts
|
|
1051
1145
|
* logDriver: 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk'|'none',
|
|
1052
1146
|
* logDriverOptions: Object<string>,
|
|
1053
|
-
* publish: Object<
|
|
1147
|
+
* publish: Object<
|
|
1148
|
+
* [hostPort string]: containerPort string # 8080
|
|
1149
|
+
* |containerPortWithProtocol string # '<containerPort>[/"tcp"|"udp"|"sctp"]'
|
|
1150
|
+
* >,
|
|
1054
1151
|
* healthCmd: Array<string>, // healthcheck command. See description
|
|
1055
1152
|
* healthInterval: 10e9|>1e6, // nanoseconds to wait between healthchecks; 0 means inherit
|
|
1056
1153
|
* healthTimeout: 20e9|>1e6, // nanoseconds to wait before healthcheck fails
|
|
@@ -1279,7 +1376,10 @@ class Docker {
|
|
|
1279
1376
|
* restartDelay: 10e9|number, // nanoseconds to delay between restarts
|
|
1280
1377
|
* logDriver: 'json-file'|'syslog'|'journald'|'gelf'|'fluentd'|'awslogs'|'splunk'|'none',
|
|
1281
1378
|
* logDriverOptions: Object<string>,
|
|
1282
|
-
* publish: Object<
|
|
1379
|
+
* publish: Object<
|
|
1380
|
+
* [hostPort string]: containerPort string # 8080
|
|
1381
|
+
* |containerPortWithProtocol string # '<containerPort>[/"tcp"|"udp"|"sctp"]'
|
|
1382
|
+
* >,
|
|
1283
1383
|
* healthCmd: Array<string>, // healthcheck command. See description
|
|
1284
1384
|
* healthInterval: 10e9|>1e6, // nanoseconds to wait between healthchecks; 0 means inherit
|
|
1285
1385
|
* healthTimeout: 20e9|>1e6, // nanoseconds to wait before healthcheck fails
|