Comments (8)
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']
}
from dockerode.
Interesting how "run" functionality keeps growing :)
Hummm, I see two options:
- Expose another argument for the start options. (not pretty, verbose)
- Automagically map options like you said. (possibly high maintenance)
Exposing another argument is indeed a bit ugly and verbose, but it gives a lot of freedom.
What do you think?
from dockerode.
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.
from dockerode.
@apocas Any further thoughts on this one? :-)
from dockerode.
Yeah, I like that one :)
But we should throw an error if there's an option that can't be translated.
Basically I want to avoid people using some new option in a Remote API future version and it being silently ignored. If we throw an error saying something like: "I don't know what to do with XPTO option, try using start_options or create_options instead." should avoid this and give an alternate route.
Want to throw a PR for this? :)
from dockerode.
Let's go @srijs way for now, I think is solves this use case pretty well.
Will deprecate the current "options" parameter, since it doesn't give complete functionality. (it's needed for container creation)
from dockerode.
Works like a charm guys!
Btw, did I mention @srijs is sitting right next to me? ;-)
from dockerode.
Ahah, No :-P
And I was worried about hurting your feelings for choosing one of the solutions lol
from dockerode.
Related Issues (20)
- Sending stdin on container HOT 3
- dockerode.getConfig().remove() HOT 1
- containerAttach is sending parameter as POST JSON payload while it shouldn't HOT 1
- Pushing an image to private registry with auth not working HOT 1
- Error while installing with pnpm
- ContainerStartOptions does not contain abortSignal property HOT 1
- Missing Changelog HOT 5
- Specifying socketPath but Dockerode is using HTTP. (bun.js) HOT 13
- Image name when we use buildImage doesn't work HOT 1
- Changelog HOT 4
- Undocumented breaking change: container.logs now produces a string HOT 8
- Error building image
- Error to get logs on some containers HOT 1
- Passing filter options to pruneImages HOT 1
- Module parse failed: Unexpected character '�' (1:0) HOT 1
- Restore exec stream
- Source directory and Dockerfile in different locations HOT 2
- Clone a container HOT 1
- unable to handle ssh network errors HOT 2
- Sending User Input via Attach or Other
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerode.