Giter Club home page Giter Club logo

Comments (8)

sreuter avatar sreuter commented on July 27, 2024

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.

apocas avatar apocas commented on July 27, 2024

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.

sreuter avatar sreuter commented on July 27, 2024

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.

sreuter avatar sreuter commented on July 27, 2024

@apocas Any further thoughts on this one? :-)

from dockerode.

apocas avatar apocas commented on July 27, 2024

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.

apocas avatar apocas commented on July 27, 2024

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.

sreuter avatar sreuter commented on July 27, 2024

Works like a charm guys!

Btw, did I mention @srijs is sitting right next to me? ;-)

from dockerode.

apocas avatar apocas commented on July 27, 2024

Ahah, No :-P

And I was worried about hurting your feelings for choosing one of the solutions lol

from dockerode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.