bake computing incorrect context path in the presence of nested include directives
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
Contributing guidelines
- I've read the contributing guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
When using the include directory to include into a.yml file b.yml and then to include into b.yml file c.yml, the context for c.yml is not calculated relative to c.yml directory but to b.yml creating a non-existing path.
$ ls a.yml b/b.yml c/c.yml
a.yml b/b.yml c/c.yml
$ cat a.yml
include:
- path:
- ./b/b.yml
services:
a:
build:
context: .
dockerfile_inline: FROM scratch
$ cat b/b.yml
include:
- path:
- ../c/c.yml
services:
b:
build:
context: .
dockerfile_inline: FROM scratch
$ cat c/c.yml
services:
c:
build:
context: .
dockerfile_inline: FROM scratch
Expected behaviour
Trying to build with bake should work.
Actual behaviour
docker buildx bake -f a.yml
[+] Building 0.2s (1/1) FINISHED docker:desktop-linux
=> [internal] load local bake definitions 0.0s
=> => reading a.yml 119B / 119B 0.0s
ERROR: unable to prepare context: path "b/c" not found
The error is clear, context for service "c" is being computed as "b/c", which is a non-existent path. It should be "c" instead.
docker buildx bake -f a.yml --print
[+] Building 0.0s (1/1) FINISHED
=> [internal] load local bake definitions 0.0s
=> => reading a.yml 119B / 119B 0.0s
{
"group": {
"default": {
"targets": [
"a",
"b",
"c"
]
}
},
"target": {
"a": {
"context": ".",
"dockerfile": "Dockerfile",
"dockerfile-inline": "FROM scratch"
},
"b": {
"context": "b",
"dockerfile": "Dockerfile",
"dockerfile-inline": "FROM scratch"
},
"c": {
"context": "b/c",
"dockerfile": "Dockerfile",
"dockerfile-inline": "FROM scratch"
}
}
}```
### Buildx version
github.com/docker/buildx v0.22.0-desktop.1 b45d7a53aa26a5e76aae051acdb15775c0e178da
### Docker info
```text
Client: Docker Engine - Community
Version: 28.0.1
Context: desktop-linux
Debug Mode: false
Plugins:
ai: Docker AI Agent - Ask Gordon (Docker Inc.)
Version: v1.1.3
Path: /Users/davi/.docker/cli-plugins/docker-ai
buildx: Docker Buildx (Docker Inc.)
Version: v0.22.0-desktop.1
Path: /Users/davi/.docker/cli-plugins/docker-buildx
cloud: Docker Cloud (Docker Inc.)
Version: 0.2.20
Path: /Users/davi/.docker/cli-plugins/docker-cloud
compose: Docker Compose (Docker Inc.)
Version: v2.34.0-desktop.1
Path: /Users/davi/.docker/cli-plugins/docker-compose
debug: Get a shell into any image or container (Docker Inc.)
Version: 0.0.38
Path: /Users/davi/.docker/cli-plugins/docker-debug
desktop: Docker Desktop commands (Beta) (Docker Inc.)
Version: v0.1.6
Path: /Users/davi/.docker/cli-plugins/docker-desktop
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.2
Path: /Users/davi/.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.27
Path: /Users/davi/.docker/cli-plugins/docker-extension
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.4.0
Path: /Users/davi/.docker/cli-plugins/docker-init
model: Docker Model Runner (Docker Inc.)
Version: v0.1.4
Path: /Users/davi/.docker/cli-plugins/docker-model
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/davi/.docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.17.0
Path: /Users/davi/.docker/cli-plugins/docker-scout
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 5
Server Version: 28.0.4
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 753481ec61c7c8955a23d6ff7bc8e4daed455734
runc version: v1.2.5-0-g59923ef
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.10.14-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 8
Total Memory: 7.654GiB
Name: docker-desktop
ID: 92deabd9-1aab-4e3d-88e7-3c4757a4b0aa
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Labels:
com.docker.desktop.address=unix:///Users/davi/Library/Containers/com.docker.docker/Data/docker-cli.sock
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
::1/128
127.0.0.0/8
Live Restore Enabled: false
Builders list
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
default docker
\_ default \_ default running v0.20.2 linux/amd64 (+2), linux/arm64, linux/arm (+2), linux/ppc64le, (3 more)
desktop-linux* docker
\_ desktop-linux \_ desktop-linux running v0.20.2 linux/amd64 (+2), linux/arm64, linux/arm (+2), linux/ppc64le, (3 more)
Configuration
See the fields above with full reproduction.
Build logs
See logs on the fields above.
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the nested a.yml, b/b.yml, and c/c.yml reproduction, then run docker buildx bake -f a.yml --print to inspect the computed contexts. Trace the bake include handling from this entry point and verify that the c service resolves its context as c rather than b/c; the original build command should then succeed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100