Skip to content
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

services with 'depends_on' cannot be extended #3220

Closed
krasi-georgiev opened this issue Mar 26, 2016 · 18 comments
Closed

services with 'depends_on' cannot be extended #3220

krasi-georgiev opened this issue Mar 26, 2016 · 18 comments

Comments

@krasi-georgiev
Copy link

Will this be supported in the future releases ?

@gingerlime
Copy link

... Not sure if this achieves the same results as extends, but you can use yml references to avoid copy&pasting and keeping this DRY inside your docker-compose.yml, e.g.

web: &web
  image: your_image
  depends_on:
    - db
  ...
web1:
  <<: *web

@aanand
Copy link

aanand commented Aug 3, 2016

What are you trying to do that requires both extends and depends_on? Can it be done with multiple Compose files instead?

@gingerlime
Copy link

I'm personally only experimenting and considering options at this stage.

I'm trying to build a zero-time rolling upgrade based on this pattern.

Perhaps multiple compose files can also be used in this case, but I haven't tried it yet. Thanks for suggesting it.

@intellent
Copy link

Why has this been closed? May I cite the official documentation here:

Note: links, volumes_from, and depends_on are never shared between services using extends. These exceptions exist to avoid implicit dependencies—you always define links and volumes_from locally. This ensures dependencies between services are clearly visible when reading the current file. Defining these locally also ensures changes to the referenced file don’t result in breakage.

I interpret this as follows: Extending services with depends_on should work, but you have to redefine your dependencies locally. Which would totally make sense to me.

Basically all my services use depends_on and networks for orchestration since links are not recommended anymore. This renders the extends mechanism useless for me.

@krasi-georgiev
Copy link
Author

i think I managed to achieve the same effect by using multiply compose files with the -f option

@intellent
Copy link

@krasi-georgiev You’re right. However, IMHO the current behavior renders the extends mechanism useless in a lot of cases. This could not be the intention, could it?

@krasi-georgiev
Copy link
Author

I don't know , some of the devs should answer that

@mlovic
Copy link

mlovic commented Feb 22, 2017

I've been wondering the same thing. I had the same interpretation of the docs as @intellent. The documentation doesn't seem to match behaviour.

Regarding @aanand's suggestion of using multiple compose files, that could work, but I think extends would fit much better in situations where services only slightly differ, or the same app/codebase takes on different "roles". For example:

web_app:
  depends_on:
    - db
  command: puma -C config/puma.yml
  ...
worker:
  extends:
    service: web_app
  command: sidekiq -C config/sidekiq.yml

for a Rails worker process

or

...
admin:
  extends:
    service: web_app
  environment:
      - ADMIN_MODE=true

for an Admin instance

Please let me know if there's anything I'm missing, thanks!

@mkozjak
Copy link

mkozjak commented Jul 10, 2017

Why is this closed once more?

@dazinator
Copy link

Can this be reopened?

@shin-
Copy link

shin- commented Aug 10, 2018

It is closed because the original reporter considers the issue resolved.

It does not need to be re-opened as:

  1. It is a duplicate of Extend a base service from the same file #1988
  2. the recommended way to have an abstract, inheritable "base definition" is to use extension fields. We still believe that depends_on should be declared ad-hoc to improve clarity and reduce complexity, but that method doesn't enforce it.

@pdfrod
Copy link

pdfrod commented Aug 14, 2018

At the very least the docs should be clarified, as I too had the same interpretation as @intellent.

@shin-
Copy link

shin- commented Aug 14, 2018

https://github.com/docker/docker.github.io/issues/new

@Kolyunya
Copy link

Kolyunya commented Oct 11, 2020

Why can't compose just ignore or skip the depends_on option while extending services and let us reuse all the other bits of service configuration? This approach would have several benefits:

  • it is backward compatible;
  • it prevents implicit service dependencies;
  • it make the extends option actually useful.

@superlevure
Copy link

I also think the implementation is not what the documentation leads us to believe, totally agree with @Kolyunya and @intellent .
So I opened a new issue: #7916

@KulykDmytro
Copy link

Folks, find weird behavior in tools:

docker-compose up
ERROR: Cannot extend service 'init' in /Users/dmytro.kulyk/projects/betlab/git/datalake/transform/airflow/docker-compose.yml: services with 'depends_on' cannot be extended

however

docker compose up
[+] Running 4/0
 ⠿ Container airflow-postgres-1   Created                                                                                                                            0.0s
 ⠿ Container airflow-init-1       Created                                                                                                                            0.0s
 ⠿ Container airflow-webserver-1  Created                                                                                                                            0.0s
 ⠿ Container airflow-scheduler-1  Created  

@ColeDCrawford
Copy link

Yep, seeing this too.

@ethanttbui
Copy link

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests