-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Closed
docker/docs
#23184Labels
Description
Description
Hi,
The docker compose documentation says that "volumes_from and depends_on are never shared between services using extends", but when I expand a service, the new service inherits the source service's depends_on
.
Steps To Reproduce
- Create compose.test.yml
services:
db:
image: postgres:15
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
PGDATA: /tmp
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres" ]
interval: 2s
timeout: 1s
retries: 5
a1:
extends:
service: db
profiles:
- a
a2:
extends:
service: db
depends_on:
a1:
condition: service_started
profiles:
- a
b1:
extends:
service: a1
profiles:
- b
b2:
extends:
service: a2
depends_on:
b1:
condition: service_started
profiles:
- b
- Run the following commend
docker compose -f compose.test.yml --profile b config --services
Following the documentation this should only run services with profile b
and the db
service. b2
depends only on b1
, so I should get db, b1 and b2
. However, I get de following error:
service "b2" depends on undefined service "a1": invalid compose project
One of the way to fix this is by adding !override
in depends_on
in service b2
like this:
b2:
extends:
service: a2
depends_on: !override
b1:
condition: service_started
profiles:
- b
If depends_on
are not meant to be inherited when using expanding services then there is bug. Otherwise, I think you should updated the documentation.
Thanks
Compose Version
Docker Compose version v2.35.1-desktop.1
Docker version 28.1.1
Docker Environment
Anything else?
No response