-
-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bind Host Volume to Container on .run() #57
Comments
I just digged a little bit deeper here. Turns out the problem is originates at the .run() implementation of dockerode, as the optional options object is passed to the container creation, but not to the actual container start call. @apocas: Any proposal on how to allow users setting options for both calls? As .run() is some kind of helper function (and not a direct endpoint in docker's REST API), why don't map given options accordingly like: .run() with... options = {
'Binds': ['/hostdir:/containerdir:rw']
} results in create_options = {
'Volumes': {
'/containerdir': {}
}
}
start_options = {
'Binds': ['/hostdir:/containerdir:rw']
} |
Interesting how "run" functionality keeps growing :) Hummm, I see two options:
Exposing another argument is indeed a bit ugly and verbose, but it gives a lot of freedom. |
How about something in between... options = {
'Binds': ['/hostdir:/containerdir:rw'], // will be translated into necessary start & creation options
'start_options': {
.. // extends start options object
},
'create_options': {
.. // extends create options object
},
} This gives us the possibility to implement high-level (helper) functions, while providing freedom on setting create & start options "manually". I know this may result in a breaking change though, but think it may be worth it. |
@apocas Any further thoughts on this one? :-) |
Yeah, I like that one :) But we should throw an error if there's an option that can't be translated. Want to throw a PR for this? :) |
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"]; });
Let's go @srijs way for now, I think is solves this use case pretty well.
|
Works like a charm guys! Btw, did I mention @srijs is sitting right next to me? ;-) |
Ahah, No :-P And I was worried about hurting your feelings for choosing one of the solutions lol |
I can't figure out how to bind a host volume into a container. According to the Remote API documentation this can be specified by setting 'Binds' like this...
Unfortunately, this doesn't seem to work. (shows contents of original container /tmp)
Can somebody point me into the right direction here? I wonder if this is a bug in the Remote API...
Btw, it works perfectly fine using the docker cli tool!
The text was updated successfully, but these errors were encountered: