Package Exports
- dockerode
- dockerode/lib/container
- dockerode/lib/image
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dockerode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dockerode
Not another Node.js Docker.io Remote API module.
Why is dockerode different from all the Docker node.js module out there:
- streams -
dockerodedoes NOT break any stream, it passes them to you allowing for some stream voodoo. - entities - containers and images are defined entities and not random static methods.
- run -
dockerodeallow you to seamless run commands in a container aladocker run. - tests -
dockerodereally aims to have a good test set, allowing to followDockerchanges easily, quickly and painfully. - ws - New websocket endpoints introduced in 0.6 are supported. (beta, do not use in production yet)
- features - ALL
DockerRemote API features implemented.
installation
npm install dockerode
getting started
to use dockerode first you need to instantiate it:
var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
var docker2 = new Docker({host: 'http://192.168.1.10', port: 3000});
//...Manipulating a container:
var container = docker.getContainer('71501a8ab0f8');
container.start(function (err, data) {
console.log(data);
});
container.remove(function (err, data) {
console.log(data);
});
//...Creating a container:
docker.createContainer({Image: 'ubuntu', Cmd: ['/bin/bash']}, function(err, container) {
container.start(function(err, data) {
//...
});
});
//...Streams goodness:
container.attach({stream: true, stdout: true, stderr: true}, function(err, stream) {
stream.pipe(process.stdout);
});
docker.createImage({fromImage: 'ubuntu'}, function(err, stream) {
stream.pipe(process.stdout);
});
//...Equivalent of docker run in dockerode:
image- container imagecmd- command to be executedstream- stream which will be used for execution output.temporary- iftruecontainer will be removed after execution ends.callback- callback caled when execution ends.
docker.run('ubuntu', 'uname -a', process.stdout, true, function(err, data) {
console.log(data.StatusCode);
});Check the tests for more examples.
notes
- Input options are directly passed to Docker.io check Docker Remote API documentation for more details.
- Return values are unchanged from Docker, official Docker.io documentation will also apply to them.
tests
Tests were implemented using mocha and chai do npm test to run them.
license
Pedro Dias <abru.pt>
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.htmlunless 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.