docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.54k stars 5.17k forks source link

extending containers with links #1495

Closed ferdynice closed 8 years ago

ferdynice commented 9 years ago

What is the rationale for not supporting extends on containers that have links?

Or is it simply not yet supported?

aanand commented 9 years ago

Explicit vs implicit. If you extend a service that has links, it now has implicit dependencies on other services in your configuration file that you can't see unless you go and look at the config of the service you're extending.

That kind of "dynamic scoping" can lead to weird bugs when dependencies change, so it's better to not define any links on the service you're extending from, and explicitly define them in the service that extends it, so that the dependencies between services are clear from just reading one file.

ferdynice commented 9 years ago

Thanks for the explanation. This is how I see it: The user should be able to decide if he/she wants to extend on containers with links. Of course powerful features can be tricky or prone to abuse. However why not let the user decide, instead of being overprotective..?

By the way, the argument of not knowing what to pull in without looking at the file your depending on also applies to volumes and possibly other options. Those are reused from the parent definition, are they not?

Finally, if this argument is really important for you, why not add an option that includes/excludes certain sections about what to extend?

In example, web should extend everything from base except links:

web:
  extends:
    service: base
    exclude: links
  ports:
    - 8000:8000
  # and other web specific entries
iafilatov commented 9 years ago

There's some discussion going on regarding this. See #1088, #1380...

hoIIer commented 9 years ago

@aanand @ferdy-galema @iafilatov

I tend to agree with @ferdy-galema that it should be up to the user to decide... Im working on a microservices project and it quickly brought up the issue of how to orchestrate/build an entire project that consists of multiple services. Compose seems great but just missing the ability to essentially allow those services to remain decoupled from the orchestration tool (the top-level compose.yml). The only thing I really want that to do is handle any project-level config/setup and also define the service locations and have it run the service.yml within each one etc... I'd like each service to be able to define their own links and dependencies etc from within that service repo since thats part of the point of microservices anyways...

Also, it seems like there are a few different tickets/issues open that touch on this but all reference each other! #1088 points to this one!

dnephin commented 8 years ago

Closing as duplicate of #1617