Registry / devops / docker-exec-websocket-client

docker-exec-websocket-client

JSON →
library3.0.0jsnpmunverified

Client library for connecting to a docker-exec-websocket-server, enabling remote execution of commands in Docker containers via WebSocket. Version 3.0.0 is stable with regular updates, supporting Node.js >12. It provides stdin/stdout/stderr streaming, TTY support, exit codes, and event hooks. Unlike raw WebSocket solutions, it handles pause/resume flow control and server shutdown events out of the box.

npm install docker-exec-websocket-client
INSTALL
IMPORT
SIG · DOCKER-EXEC-WEBSOC
D
docker-exec-websocket-client
devopsjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

DockerClient
import DockerClient from 'docker-exec-websocket-client'
const DockerClient = require('docker-exec-websocket-client')
ESM supported via named exports; default import works.
DockerClient
const DockerClient = require('docker-exec-websocket-client')
CommonJS require works as the package uses module.exports.
DockerClient
import { DockerClient } from 'docker-exec-websocket-client'
Named import also supported in ESM.

Connects to a docker-exec-websocket server, pipes local stdin to remote command, and streams stdout/stderr back.

import DockerClient from 'docker-exec-websocket-client'; const client = new DockerClient({ url: 'ws://localhost:8081/a', tty: 'true', command: '/bin/bash', }); await client.execute(); process.stdin.pipe(client.stdin); client.stdout.pipe(process.stdout); client.stderr.pipe(process.stderr); client.on('exit', (exitCode) => { process.exit(exitCode); });
Debug
Known issues
gotchaThe url must be a full WebSocket URL including path (e.g., 'ws://host:port/path'). Omitting path or using incorrect protocol leads to connection failure.
fix
Ensure the URL ends with the correct endpoint (e.g., '/a').
affects: >=1.0.0
gotchaThe tty parameter is a string ('true'/'false'), not a boolean. Using boolean true will be coerced to string, but best practice is to pass a string.
fix
Pass tty: 'true' instead of tty: true.
affects: >=1.0.0
gotchaclient.execute() must be called before piping streams; otherwise data may be lost.
fix
Call await client.execute() before setting up pipes.
affects: >=1.0.0
breakingIn v3.0.0, the package switched to ESM by default. Using require() without proper CommonJS interop may fail.
fix
Use import syntax or enable CommonJS via bundler settings.
affects: >=3.0.0
Errors
Common errors & fixes
Error: connect ECONNREFUSED ws://localhost:8081/a
The docker-exec-websocket-server is not running or the port/host is incorrect.
fix
Start the server or verify the URL (e.g., ws://localhost:8081/a).
TypeError: client.execute is not a function
Using CommonJS require() while the package is ESM-only.
fix
Use import DockerClient from 'docker-exec-websocket-client' or configure your bundler to handle ESM.
SyntaxError: Cannot use import statement outside a module
Running Node.js without 'type':'module' in package.json.
fix
Add 'type':'module' to your package.json or use .mjs extension.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
wsrequiredWebSocket implementation used for communication
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
docker-exec-websocket-client — npm install docker-exec-websocket-client · libregistry