Skip to content

[BUG] depends_on is NOT ignored when extending from a service #12360

@LennyN95

Description

@LennyN95

Description

According to the documentation, the depends_on declaration should not be derived when extending a service:

volumes_from and depends_on are never shared between services that use extends. These exceptions exist to avoid implicit dependencies; you always define volumes_from locally. This ensures that the dependencies between the services are clearly visible when reading the current file. The local definition also ensures that changes to the referenced file do not break anything.
https://docs.docker.com/compose/how-tos/multiple-compose-files/extends/

However, if you extend a service that depends on a service that is not declared in the compose file, an error is issued:

service "aaa" depends on undefined service "bbb": invalid compose project

I didn't expect an error because according to the documentation depends_on should never be shared between services with extends.

Steps To Reproduce

compose.yaml

name: setup

services:
   aaa:
      depends_on:
          bbb:
             condition: service_healthy
   bbb:

compose2.yaml

name: setup

services:
   aaa:
      extends:
         file: compose.yaml
         service: aaa

run command:

docker compose -f compose2.yaml up -d

Compose Version

Docker Compose version v2.30.3-desktop.1

Docker Environment


Anything else?

I reduced the configuration to only the parts causing the problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions