Skip to content

Instantly share code, notes, and snippets.

@masonforest
Created September 24, 2014 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masonforest/10ac17877c0af6d64d54 to your computer and use it in GitHub Desktop.
Save masonforest/10ac17877c0af6d64d54 to your computer and use it in GitHub Desktop.
var Docker = require('dockerode');
var docker = new Docker({ socketPath: false, host: '192.168.59.103', port: '2375' });
var optsc = {
'Hostname': '',
'User': '',
'AttachStdin': true,
'AttachStdout': true,
'AttachStderr': true,
'Tty': false,
'OpenStdin': true,
'StdinOnce': true,
'Env': null,
'Cmd': ['wc','-c'],
'Dns': ['8.8.8.8', '8.8.4.4'],
'Image': 'ubuntu',
'Volumes': {},
'VolumesFrom': ''
};
function handler(err, container) {
var attach_opts = {stream: true, stdin: true, stdout: true, stderr: true};
container.attach(attach_opts, function handler(err, stream) {
stream.pipe(process.stdout);
container.start(function(err, data) {
stream.write('hello');
stream.end();
});
});
}
docker.createContainer(optsc, handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment