diff --git a/lib/docker.js b/lib/docker.js index fd86391..b087071 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -197,6 +197,26 @@ Docker.prototype.version = function(callback) { }); }; +Docker.prototype.ping = function(callback) { + if (!callback && typeof(opts) === 'function') { + callback = opts; + opts = null; + } + + var optsf = { + path: '/_ping', + method: 'GET', + statusCodes: { + 200: true, + 500: "server error" + } + }; + + this.modem.dial(optsf, function(err, data) { + callback(err, data); + }); +}; + Docker.prototype.getEvents = function(opts, callback) { if (!callback && typeof(opts) === 'function') { callback = opts; diff --git a/test/docker.js b/test/docker.js index aa908c8..36378e0 100644 --- a/test/docker.js +++ b/test/docker.js @@ -68,6 +68,19 @@ describe("#docker", function() { }); }); + describe("#getPing", function() { + it("should ping server", function(done) { + this.timeout(30000); + + function handler(err, data) { + expect(err).to.be.null; + done(); + } + + docker.ping(handler); + }); + }); + describe('#pull', function() { this.timeout(120000);