See apocas/dockerode#108.
npm install dockerode-bluebird
Then:
var Docker = require("dockerode-bluebird");
var docker = new Docker({socketPath: '/var/run/docker.sock'});
var data = {
Image: 'mesoscloud/zookeeper:3.4.6-ubuntu-14.04',
//Cmd: [],
'ExposedPorts': {
'2181/tcp': {}
},
name: 'zookeeper',
HostConfig: {
PortBindings: {
"2181/tcp": [
{
"HostPort": "2181"
}
]
}
}
};
docker.createContainerAsync(data).then( function(container) {
console.log('startZookeeper container = ' + container);
return container.startAsync();
}).catch(function(error) {
console.log('startZookeeper error = ' + error);
}).finally( function() {
console.log('startZookeeper finally ');
});