Skip to content

Commit

Permalink
Merge pull request #155 from rmg/fix-container-commit
Browse files Browse the repository at this point in the history
Fix container commit
  • Loading branch information
apocas committed Jul 7, 2015
2 parents f787502 + d79b5f6 commit 6087a67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Container.prototype.exec = function(opts, callback) {
Container.prototype.commit = function(opts, callback) {
var args = util.processArgs(opts, callback, this.defaultOptions.commit);

opts.container = this.id;
args.opts.container = this.id;

var optsf = {
path: '/commit?',
Expand Down
15 changes: 15 additions & 0 deletions test/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,21 @@ describe("#container", function() {
});
});

describe("#commit", function() {
it("should commit a container", function(done) {
this.timeout(30000);
var container = docker.getContainer(testContainer);

function handler(err, stream) {
expect(err).to.be.null;
expect(stream).to.be.ok;
done();
}

container.commit({comment: 'dockerode commit test'}, handler);
});
});

describe("#stop", function() {
it("should stop a container", function(done) {
this.timeout(30000);
Expand Down
12 changes: 10 additions & 2 deletions test/spec_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@ http.globalAgent.maxSockets = 1000;

var Docker = require('../lib/docker');
var fs = require('fs');
var url = require('url');

// For Mac OS X:
// socat -d -d unix-l:/tmp/docker.sock,fork tcp:<docker-host>:4243
// DOCKER_SOCKET=/tmp/docker.sock npm test

var dockerURL = {
hostname: process.env.DOCKER_HOST || '127.0.0.1',
port: process.env.DOCKER_PORT || '5555',
};
if (/:\/\//.test(process.env.DOCKER_HOST)) {
dockerURL = url.parse(process.env.DOCKER_HOST);
}

var socket = process.env.DOCKER_SOCKET || '/var/run/docker.sock';
var isSocket = fs.existsSync(socket) ? fs.statSync(socket).isSocket() : false;
var docker;

if (!isSocket) {
console.log('Trying TCP connection...');
docker = new Docker({host: process.env.DOCKER_HOST || 'http://127.0.0.1', port: process.env.DOCKER_PORT || 5555});
dockert = new Docker({host: process.env.DOCKER_HOST || 'http://127.0.0.1', port: process.env.DOCKER_PORT || 5555, timeout: 1});
docker = new Docker({host: dockerURL.hostname, port: dockerURL.port});
dockert = new Docker({host: dockerURL.hostname, port: dockerURL.port, timeout: 1});
} else {
docker = new Docker({ socketPath: socket });
dockert = new Docker({ socketPath: socket, timeout: 1 });
Expand Down

0 comments on commit 6087a67

Please sign in to comment.