dockerode
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@balena/dockerignore | 1.0.2 | 12.08 kB | Apache-2.0 | prod | |
docker-modem | 3.0.8 | 12.41 kB | Apache-2.0 | prod | 2 |
tar-fs | 2.0.1 | 7.11 kB | MIT | prod |
Dockerode is a Node.js module that provides an interface to interact with the Docker Remote API programmatically. It supports all Docker Remote API features, including using promises or callbacks for handling asynchronous operations. Dockerode also works with Docker streams, allowing direct manipulation and handling. It emphasizes a feature-rich environment, adhering to Docker changes quickly and effortlessly.
To use Dockerode, you'll first need to install it using npm as follows:
npm install dockerode
You can then import Dockerode into a JavaScript file and initiate Dockerode with various options. Here's how you can do this in your code:
var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
You can also specify different options while initiating Dockerode. For example:
var docker = new Docker({
host: 'http://mydockerhost.com',
port: process.env.DOCKER_PORT || 2375,
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem'),
version: 'v1.25' // must correspond to Docker API version
});
Manipulating a Docker container would look like this:
// Create a container entity. Does not query API.
var container = docker.getContainer('71501a8ab0f8');
container.start(function (err, data) {
console.log(data);
});
container.remove(function (err, data) {
console.log(data);
});
You can also operate on containers using promise-based approaches. Dockerode accommodates both styles, aiming to make Docker operations as flexible as possible for developers.
The comprehensive Dockerode documentation can be found on the Docker API documentation page: https://docs.docker.com/engine/api/latest/. Detailed information about the Docker functions that Dockerode supports can be found right in the Dockerode readme file in the 'Documentation' section. Examples are also available to provide more specific use cases.