container: introduce per-instance default options#61
Conversation
In order to be able to set default options for common operations on a container, introduce a default options object per operation that can be overwritten from the outside. Together with apocas#60 this resolves apocas#57, because you can now do: docker.run(..., function (...) { ... }).on('container', function (container) { container.defaultOptions.start.Binds = ["/tmp:/tmp:rw"]; });
|
I like this pattern/combo. But I think I see a problem, imagine that someone wants to define a defaultOption for "attach" instead of "start". This may asynchronous fail. (with "start" it will probably work, since "attach" is done first giving it time) https://github.com/apocas/dockerode/blob/master/lib/docker.js#L258 |
|
There'll be no problem with that, because semantically all event handlers for the |
|
👍 Want do drop that run->start example into readme.md? We should deprecate the current "options" parameter from run, since it doesn't give complete functionality and this pattern is way superior. |
|
Will add the example myself, since I'm prepping the next release right now and really wanna to have this in :) |
container: introduce per-instance default options
|
Are you talking about the |
|
Duh you are right. Will express this clearly in the documentation. |
|
Published v1.3.0 |
In order to be able to set default options for common operations on a container,
introduce a default options object per operation that can be overwritten from the outside.
Together with #60 this resolves #57, because you can now do: