Skip to content

Consider documenting Hostconfig.Binds instead of defaultOptions.start.Binds #385

@toolness

Description

@toolness

Hello!

The README contains the following example code:

docker.run('ubuntu', ['bash', '-c', 'uname -a'], [process.stdout, process.stderr], {Tty:false}, function (err, data, container) {
  //...
}).on('container', function (container) {
  container.defaultOptions.start.Binds = ["/tmp:/tmp:rw"];
});

However, setting container.defaultOptions.start.Binds, at least during the container event callback, doesn't actually seem to do anything, at least when running Docker for Windows (the native version, not Docker Toolbox). What does seem to work is passing Hostconfig.Binds in the options to docker.run, which your example at examples/run.js does:

docker.run('ubuntu', [], process.stdout, {
  'Volumes': {
    '/stuff': {}
  },
  'ExposedPorts': {
    '80/tcp': {}
  },
  'Hostconfig': {
    'Binds': ['/home/vagrant:/stuff'],
  }
}, function(err, data, container) {
  console.log(data.StatusCode);
});

It took me a few hours to figure this out, especially since the defaultOptions.start.Binds method did seem to work earlier this year on an OS X system. I'm not sure if it's the Docker API that's changed or if it has something to do with me being on Windows native, but I figured I'd mention it here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions