Registry / devops / docker-cli-js

docker-cli-js

JSON →
library2.10.0jsnpmunverified

Node.js wrapper for the Docker CLI that executes docker commands via child_process.exec, returning parsed output (raw, success, imageId, etc.) as a promise. Current stable version is 2.10.0 with TypeScript types included. Maintained by Quobject, the library wraps the Docker CLI tool — not the Docker SDK — and supports custom machines, working directories, and echo output. Useful for scripting Docker operations from Node without the Docker SDK, but inherently couples to the CLI availability and command syntax.

npm install docker-cli-js
INSTALL
IMPORT
SIG · DOCKER-CLI-JS
D
docker-cli-js
devopsjavascriptv2.10.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dockerCommand
import { dockerCommand } from 'docker-cli-js'
const dockerCommand = require('docker-cli-js').dockerCommand
ESM import works; CommonJS require works with destructuring as shown in wrong pattern, but it's not wrong per se — just a style difference.
Docker
import { Docker } from 'docker-cli-js'
const Docker = require('docker-cli-js').Docker
Both import styles are valid. Class-based API for promise chaining.
DockerOptions
import { DockerOptions } from 'docker-cli-js'
const DockerOptions = require('docker-cli-js').Options
The older API exported 'Options' class; renamed to 'DockerOptions' in TypeScript rewrite. Both exist for backward compatibility.
Options
import { Options } from 'docker-cli-js'
const Options = require('docker-cli-js').Options
Alias for DockerOptions, kept for backward compatibility.

Demonstrates async/await usage of dockerCommand with default options to list containers.

import { dockerCommand } from 'docker-cli-js'; async function main() { try { const result = await dockerCommand('ps', { machineName: null, currentWorkingDirectory: null, echo: false, }); console.log('Containers:', result.raw); } catch (err) { console.error('Docker command failed:', err); } } main();
Debug
Known issues
gotchaUses child_process.exec internally; vulnerable to command injection if user input is passed unsanitized.
fix
Sanitize or whitelist command parts; do not pass unsanitized user input.
affects: >=2.0.0
breakingDockerOptions renamed from Options in v2.0.0 when rewritten to TypeScript.
fix
Use DockerOptions instead of Options, or import Options as alias.
affects: >=2.0.0
breakingPromise-based API changed; removed callback style in v2.0.0.
fix
Use .then() or async/await; no longer supports callbacks.
affects: >=2.0.0
deprecatedOptions class is deprecated in favor of DockerOptions; kept for backward compatibility.
fix
Use DockerOptions.
affects: >=2.0.0
gotchamachineName: null uses local Docker; non-null expects Docker Machine name. If Docker Machine not set up, command may fail.
fix
Ensure Docker is accessible or set machineName to a valid machine.
affects: *
Errors
Common errors & fixes
Error: spawn docker ENOENT
Docker CLI not installed or not in PATH.
fix
Install Docker and ensure it's accessible from terminal.
TypeError: env is not iterable
Deprecated env option usage; custom environment passed incorrectly.
fix
Pass options with env as an object of key-value pairs, not an array.
Cannot find module 'docker-cli-js'
Package not installed or import path wrong.
fix
Run `npm install docker-cli-js` and use correct import as shown in imports section.
Upgrade
Version history
2.10.0latest on npm
Audit
Dependencies
core-jsrequiredPolyfills for older Node.js versions (used since 2.1.0 rewrite)
Agent activity
4 hits · last 30 days
node
4
Resources
docker-cli-js — npm install docker-cli-js · libregistry