Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
docker-modem
Advanced tools
The docker-modem npm package is a low-level Docker API client for Node.js. It allows developers to interact with Docker's REST API programmatically, enabling them to manage Docker containers, images, networks, and more directly from their Node.js applications.
Managing Containers
This feature allows you to create and manage Docker containers. The code sample demonstrates how to create a new container using the 'alpine' image and run a simple command inside it.
const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
const createContainer = async () => {
const opts = {
path: '/containers/create',
method: 'POST',
options: {
Image: 'alpine',
Cmd: ['echo', 'Hello World']
}
};
docker.dial(opts, (err, data) => {
if (err) throw err;
console.log(data);
});
};
createContainer();
Managing Images
This feature allows you to manage Docker images. The code sample demonstrates how to pull the 'alpine' image from Docker Hub.
const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
const pullImage = async () => {
const opts = {
path: '/images/create',
method: 'POST',
options: {
fromImage: 'alpine',
tag: 'latest'
}
};
docker.dial(opts, (err, data) => {
if (err) throw err;
console.log(data);
});
};
pullImage();
Managing Networks
This feature allows you to manage Docker networks. The code sample demonstrates how to create a new network with the 'bridge' driver.
const Docker = require('docker-modem');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
const createNetwork = async () => {
const opts = {
path: '/networks/create',
method: 'POST',
options: {
Name: 'my_network',
Driver: 'bridge'
}
};
docker.dial(opts, (err, data) => {
if (err) throw err;
console.log(data);
});
};
createNetwork();
Dockerode is a high-level Docker API client for Node.js. It provides a more user-friendly interface compared to docker-modem and includes additional abstractions to simplify common tasks. While docker-modem is more low-level and closer to the raw Docker API, dockerode offers a more convenient and higher-level API for managing Docker resources.
Node-docker-api is another Docker API client for Node.js. It offers a balance between low-level control and high-level convenience. It provides a promise-based interface, making it easier to work with asynchronous operations compared to docker-modem's callback-based approach.
Docker's Remote API network layer module.
docker-modem
will help you talking with Docker
, since it already implements all the network strategies needed to support all Docker
's Remote API endpoints.
It is the module powering (network wise) dockerode and other modules.
mocha
and chai
. Run them with npm test
.docker-modem
.Pedro Dias - @pedromdias
Licensed under the Apache license, version 2.0 (the "license"); You may not use this file except in compliance with the license. You may obtain a copy of the license at:
http://www.apache.org/licenses/LICENSE-2.0.html
Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license.
FAQs
Docker remote API network layer module.
The npm package docker-modem receives a total of 363,943 weekly downloads. As such, docker-modem popularity was classified as popular.
We found that docker-modem 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.