dockerode – Not another Node.js module

While developing I looked for Node.js modules that implemented the Remote API.

I found a few, the majority was  unfinished lacking a lot of functionality and tests.

Things I was looking for:

  • Complete feature set
  • Tests
  • Leverage streams
  • Good abstraction

I didn’t found a module with these characteristics or with a code base ready to accept contributions.

At the time I ended up forking fixed some bugs it had (this module was revamped recently and it’s better now) and implemented some functionality I needed. But all this was really quick patch, I knew that someday I had to do something about this.

That day came yesterday, and another node.js module was born… it’s main objectives are those four points I enumerated in this post.

I called it dockerode (docker+node yes naming stuff isn’t a skill I’m proud of…)

How it works and what it can do


var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});
var docker2 = new Docker({host: '', port: 3000});

By leveraging streams it allows to do cool stuff like:

container.attach({stream: true, stdout: true, stderr: true}, function(err, stream) {

Containers and images are entities:

docker.createContainer({Image: 'ubuntu', Cmd: ['/bin/bash']}, function(err, container) {
  container.start(function(err, data) {

var container = docker.getContainer('71501a8ab0f8');
container.inspect(function(err, data) {


“docker run” implementation:

//, cmd, stream, temporary, callback)'ubuntu', 'uname -a', process.stdout, true, function(err, data) {

Installation and tests

npm install dockerode

Tests use mocha and chai.js


  • Feature set is almost complete, tests are about 85%.
  • New WebSockets endpoints added in Docker v0.6 will be supported soon.