Skip to content

Commit

Permalink
maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
apocas committed Dec 28, 2014
1 parent a21968b commit 8e44adf
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ var docker2 = new Docker({host: 'http://192.168.1.10', port: 3000});
var docker3 = new Docker({protocol:'http', host: '127.0.0.1', port: 3000});
var docker4 = new Docker({host: '127.0.0.1', port: 3000}); //defaults to http

//protocol http vs https is automatically detected
var docker5 = new Docker({
protocol: 'https',
host: '192.168.1.10',
port: process.env.DOCKER_PORT || 2375,
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem')
});

var docker6 = new Docker({
protocol: 'https', //you can enforce a protocol
host: '192.168.1.10',
port: process.env.DOCKER_PORT || 2375,
ca: fs.readFileSync('ca.pem'),
Expand Down
35 changes: 35 additions & 0 deletions examples/duplexstreams.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var Docker = require('../lib/docker');

var docker = new Docker();

var createContainer = function(i) {
console.log("creating container " + i);
return docker.createContainer({
Cmd: '/bin/bash',
Image: 'ubuntu:12.04',
OpenStdin: true,
Tty: true
}, function(err, container) {
console.log("attaching to container " + i);
return container.attach({
stream: true,
stdin: true,
stdout: true
}, function(err, ttyStream) {
return setTimeout(function() {
console.log("ending container " + i + " tty stream");
//console.log(ttyStream);
ttyStream.end();
return container.remove({
force: true
}, function() {
return console.log("container " + i + " removed");
});
}, 5000);
});
});
};

for (var i = 0; i <= 20; i++) {
setTimeout(createContainer, i * 250, i);
}
17 changes: 9 additions & 8 deletions test/docker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var expect = require('chai').expect;
var docker = require('./spec_helper').docker;

var testImage = 'ubuntu:14.04';

describe("#docker", function() {

describe("#checkAuth", function() {
Expand Down Expand Up @@ -98,9 +100,8 @@ describe("#docker", function() {
this.timeout(120000);

// one image with one tag
var repoTag = 'ubuntu:latest';
var repoTag = testImage;

// XXX: Should this be an extra abstraction in docker.js?
function locateImage(image, callback) {
docker.listImages(function(err, list) {
if (err) return callback(err);
Expand Down Expand Up @@ -161,7 +162,7 @@ describe("#docker", function() {
});
}

var ee = docker.run('ubuntu', ['bash', '-c', 'uname -a'], process.stdout, handler);
var ee = docker.run(testImage, ['bash', '-c', 'uname -a'], process.stdout, handler);
ee.on('container', function (container) {
expect(container).to.be.ok;
});
Expand All @@ -186,7 +187,7 @@ describe("#docker", function() {
});
}

docker.run('ubuntu', ['bash', '-c', 'uname -a'], process.stdout, handler);
docker.run(testImage, ['bash', '-c', 'uname -a'], process.stdout, handler);
});

it("should run a command with start options", function(done){
Expand All @@ -203,7 +204,7 @@ describe("#docker", function() {
});
});
}
docker.run('ubuntu', ['bash', '-c', 'uname -a'], process.stdout, {}, {Privileged : true}, handler);
docker.run(testImage, ['bash', '-c', 'uname -a'], process.stdout, {}, {Privileged : true}, handler);
});

it("should run a command with create options", function(done){
Expand All @@ -219,7 +220,7 @@ describe("#docker", function() {
});
});
}
docker.run('ubuntu', ['bash', '-c', 'uname -a'], process.stdout, {}, handler);
docker.run(testImage, ['bash', '-c', 'uname -a'], process.stdout, {}, handler);
});
});

Expand All @@ -242,7 +243,7 @@ describe("#docker", function() {
});
}

docker.createContainer({Image: 'ubuntu', Cmd: ['/bin/bash'], name: 'test'}, handler);
docker.createContainer({Image: testImage, Cmd: ['/bin/bash'], name: 'test'}, handler);
});
});

Expand All @@ -261,7 +262,7 @@ describe("#docker", function() {
});
}

docker.createImage({fromImage: 'ubuntu'}, handler);
docker.createImage({fromImage: testImage}, handler);
});
});

Expand Down
2 changes: 1 addition & 1 deletion test/image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var expect = require('chai').expect;
var docker = require('./spec_helper').docker;

var testImage = 'ubuntu';
var testImage = 'ubuntu:14.04';

describe("#image", function() {

Expand Down

0 comments on commit 8e44adf

Please sign in to comment.