compose
compose copied to clipboard
[BUG] random build context path for services with a long(ish) chain of extends with compose 2.24.2
Description
Please see the attached screen recording:
Screencast from 2024-01-23 14-47-13.webm
Steps To Reproduce
- Create
compose.yaml
services:
service:
extends:
file: dir/file.yaml
service: service
- Create
dir/file.yaml
services:
level1:
build:
context: ..
level2:
extends: level1
service:
extends: level2
build:
target: target
- Try to reproduce the issue
watch -n 0.1 docker compose config --no-path-resolution
For me, the behavior is as in the attached screen recording.
If the service
from dir/file.yaml
extends the level1
service instead, the problem disappears.
If the service
from dir/file.yaml
lacks the build
block, I get, sometimes, the service "service" has neither an image nor a build context specified: invalid compose project
error.
Compose Version
Docker Compose version v2.24.2
Docker Environment
No response
Anything else?
No response
Can you please try to reproduce with v2.24.3 ? I guess this has same cause as https://github.com/docker/compose/issues/11377 (while the fact this isn't deterministic sounds weird to me)
v2.24.3? It's not yet released ... (I was actually hoping that the fix for #11377 fixes this randomness too, but that's now fixed in v2.24.2 and I still get the nondeterministic behavior, so I found a way to reproduce it (at least for me))
oh sorry my bad, I got confused with the many releases in a row. So this issue applies to latest. Let me investigate
Tried to reproduce with the provided example, but get a stable context definition set to .
(including having build
removed)
I just noticed in your screen recording you're running docker-compose
, not docker compose
(space). Can you double check docker-compose version
actually return v2.24.2 ? Otherwise you have an older version in your PATH
:( Maybe running inside a docker helps:
services:
bug:
build:
dockerfile_inline: |
FROM docker:${DOCKER_CLI_TAG:-cli}
WORKDIR /root/src
COPY <<'EOF' /root/src/compose.yaml
services:
service:
extends:
file: dir/file.yaml
service: service
EOF
COPY <<'EOF' /root/src/dir/file.yaml
services:
level1:
build:
context: ..
level2:
extends: level1
service:
extends: level2
build:
target: target
EOF
init: true
entrypoint: watch -n0.1 docker compose config --no-path-resolution
I can reproduce it like this (and the current docker:cli image has v2.24.2 of the compose plugin)
With a longer chain I consistently get the wrong path (dir instead of .):
services:
bug:
build:
pull: true
dockerfile_inline: |
FROM docker:${DOCKER_CLI_TAG:-cli}
WORKDIR /root/src
COPY <<'EOF' compose.yaml
services:
service:
extends:
file: dir/file.yaml
service: service
EOF
COPY <<'EOF' dir/file.yaml
services:
level1:
build:
context: ..
level2:
extends: level1
level3:
extends: level2
level4:
extends: level3
level5:
extends: level4
level6:
extends: level5
level7:
extends: level6
level8:
extends: level7
service:
extends: level8
build:
target: target
EOF
init: true
entrypoint: watch -n0.1 docker compose config --no-path-resolution