Gathering detailed insights and metrics for dockerode-utils
Gathering detailed insights and metrics for dockerode-utils
Gathering detailed insights and metrics for dockerode-utils
Gathering detailed insights and metrics for dockerode-utils
npm install dockerode-utils
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
17 Commits
1 Forks
4 Watching
2 Branches
2 Contributors
Updated on 30 Apr 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-35%
299
Compared to previous day
Last week
-18.5%
2,096
Compared to previous week
Last month
-23%
9,274
Compared to previous month
Last year
35%
115,381
Compared to previous year
1
7
Set of useful functions for working with dockerode.
stdout
.npm
1npm install dockerode-utils --save
yarn
1yarn add dockerode-utils
pullImageAsync(dockerode, imageName, onProgress?)
1pullImageAsync(dockerode: Dockerode, imageName: string, onProgress?: (output: string) => void): void
Will pull docker image, you can wait for finish or track a progress. If you forget to specify
:tag
, it'll download :latest
1/** 2 * Example how to pull alpine:latest image from dockerhub 3 */ 4import * as Dockerode from 'dockerode'; 5import { pullImageAsync } from 'dockerode-utils'; 6 7const dockerode = new Dockerode(); 8await pullImageAsync(dockerode, 'alpine:latest');
execCommand(container, cmd)
1execCommand(container: Dockerode.Container, cmd: string[]): string[]
Execute shell command in container and returns output as string[]
.
1/** 2 * Print list of env from docker container 3 */ 4import * as Dockerode from 'dockerode'; 5import { execCommand } from 'dockerode-utils'; 6 7// first, we need to create a container 8const dockerode = new Dockerode(); 9const alpineContainer = await dockerode.run('alpine', [], {}, null); 10 11const envList = execCommand(alpineContainer, ['env']); 12console.log(envList); 13 14// command with argument 15const envList2 = execCommand(alpineContainer, ['env', '--help']); 16console.log(envList2);
waitForOutput(container, predicate, timeout = 15000)
1waitForOutput(container: Dockerode.Container, predicate: (output: string) => boolean, timeout: number = 15000)
Wait for specific output from container. Useful, when you're working with container, in which is running daemon and you have to wait for specific output/line to appears in container.
1/** 2 * Example with waiting for specific output. 3 * Here, we're waiting for 'InnoDB: 5.7.18 started' to appears in mysql container 4 * only after that, we know that mysql container is fully initialized and we can 5 * continue executing commands 6 */ 7 import * as Dockerode from 'dockerode'; 8 import { waitForOutput } from 'dockerode-utils'; 9 10const dockerode = new Dockerode(); 11const mysqlContainer = await dockerode.run('mysql:5.7.18', [], {}, null); 12 13await waitForOutput(mysqlContainer, (line) => line === 'InnoDB: 5.7.18 started'); 14console.log('MySql db started');
imageExists(dockerode, ...imageNames)
1imageExists(dockerode: Dockerode, ...imageNames: string | string[]): boolean
Check if images with imageNames
exist. You can check more than one image at once, like imageExists(dockerode, ['mongo', 'mysql'])
or only one imageExists(dockerode, 'mongo')
. In case, you won't define :tag
it'll check if any image with imageName
prefix exists.
Feel free to contribute with useful function that you're using daily and it can be helpful for others.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/17 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
59 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More