Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
apocas committed Aug 14, 2014
1 parent 5fa19b4 commit f45af15
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions examples/timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var Docker = require('../lib/docker');
var fs = require('fs');

var socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock';
var stats = fs.statSync(socket);

if (!stats.isSocket()) {
throw new Error("Are you sure the docker is running?");
}

//you may specify a timeout for all operations, allowing to make sure you don't fall into limbo if something happens in docker
var docker = new Docker({host: 'http://127.0.0.1', port: 2375, timeout: 1});

docker.createContainer({Image: 'ubuntu', Cmd: ['/bin/bash']}, function (err, container) {
container.start(function (err, data) {
container.top({ps_args: 'aux'}, function(err, data) {
console.log(data);
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dockerode",
"description": "Docker.io / Docker remote API implementation.",
"version": "2.0.1",
"version": "2.0.2",
"author": "Pedro Dias <petermdias@gmail.com>",
"maintainers": [
"apocas <petermdias@gmail.com>"
Expand Down
13 changes: 13 additions & 0 deletions test/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ describe("#docker", function() {
});
});

describe("#testTimeout", function() {
it("should timeout", function(done) {
this.timeout(30000);

function handler(err, data) {
expect(err).to.not.be.null;
done();
}

dockert.ping(handler);
});
});

describe('#pull', function() {
this.timeout(120000);

Expand Down
5 changes: 4 additions & 1 deletion test/spec_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ var docker;
if (!stats.isSocket()) {
console.log('Trying TCP connection...');
docker = new Docker({host: process.env.DOCKER_HOST || 'http://127.0.0.1', port: process.env.DOCKER_PORT || 3000});
dockert = new Docker({host: process.env.DOCKER_HOST || 'http://127.0.0.1', port: process.env.DOCKER_PORT || 3000, timeout: 1});
} else {
docker = new Docker({ socketPath: socket });
dockert = new Docker({ socketPath: socket, timeout: 1 });
}

module.exports = {
'docker': docker
'docker': docker,
'dockert': dockert
};

0 comments on commit f45af15

Please sign in to comment.