Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@types/dockerode
Advanced tools
TypeScript definitions for dockerode
@types/dockerode provides TypeScript type definitions for the dockerode library, which is a Node.js module for managing Docker containers and images. It allows developers to interact with Docker's API in a type-safe manner, making it easier to write and maintain code that manages Docker resources.
Managing Docker Containers
This feature allows you to create and start Docker containers programmatically. The code sample demonstrates how to create a container from the 'ubuntu' image and start it.
const Docker = require('dockerode');
const docker = new Docker();
docker.createContainer({ Image: 'ubuntu', Cmd: ['/bin/bash'] }, function (err, container) {
container.start(function (err, data) {
console.log('Container started');
});
});
Managing Docker Images
This feature allows you to pull Docker images from a registry. The code sample demonstrates how to pull the 'ubuntu' image and track the progress of the download.
const Docker = require('dockerode');
const docker = new Docker();
docker.pull('ubuntu', function (err, stream) {
docker.modem.followProgress(stream, onFinished, onProgress);
function onFinished(err, output) {
console.log('Image pulled');
}
function onProgress(event) {
console.log(event);
}
});
Inspecting Docker Containers
This feature allows you to inspect the details of a Docker container. The code sample demonstrates how to retrieve and log the details of a container with a specific ID.
const Docker = require('dockerode');
const docker = new Docker();
docker.getContainer('container_id').inspect(function (err, data) {
console.log(data);
});
Listing Docker Containers
This feature allows you to list all Docker containers. The code sample demonstrates how to retrieve and log a list of all containers, including stopped ones.
const Docker = require('dockerode');
const docker = new Docker();
docker.listContainers({ all: true }, function (err, containers) {
console.log(containers);
});
docker-cli-js is a Node.js module that provides a simple interface to interact with Docker using the command line interface (CLI). Unlike dockerode, which interacts directly with the Docker API, docker-cli-js executes Docker CLI commands and parses the output. This can be useful for scenarios where you prefer or need to use the Docker CLI.
node-docker-api is another Node.js module for interacting with Docker's API. It provides a promise-based interface, which can be more convenient for handling asynchronous operations compared to dockerode's callback-based approach. It also offers a more modern and streamlined API design.
dockerode-promise is a wrapper around dockerode that adds promise support. This package allows you to use promises instead of callbacks when working with dockerode, making it easier to write and manage asynchronous code. It is particularly useful for developers who prefer using promises or async/await syntax.
npm install --save @types/dockerode
This package contains type definitions for dockerode (https://github.com/apocas/dockerode).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dockerode.
These definitions were written by Carl Winkler, Nicolas Laplante, ByeongHun Yoo, Ray Fang, Marius Meisenzahl, Rob Moran, Cameron Diver, Pascal Sthamer, and Luis Rueda.
FAQs
TypeScript definitions for dockerode
The npm package @types/dockerode receives a total of 538,741 weekly downloads. As such, @types/dockerode popularity was classified as popular.
We found that @types/dockerode demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.