Repository navigation
bake in v0.23 doesn't support targets with dots #3360
Copy link
Copy link
Closed
Labels
Milestone
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 dealing with a compose.yaml that defines additional build contexts, e.g.:
---
services:
image1.0:
image: test:latest
build:
context: .
dockerfile: Dockerfile
image2.0:
image: test:dev
build:
context: ./2.0
dockerfile: Dockerfile
x-bake:
contexts:
base: target:image1.0
bake fails to find the target image1.0:
docker buildx bake -f compose.yaml --progress plain
#0 building with "default" instance using docker driver
#1 [internal] load local bake definitions
#1 reading compose.yaml 331B / 331B done
#1 DONE 0.0s
ERROR: failed to find target image1.0
If we replace the dot with an underscore in the contexts section only:
---
services:
image1.0:
image: test:latest
build:
context: .
dockerfile: Dockerfile
image2.0:
image: test:dev
build:
context: ./2.0
dockerfile: Dockerfile
x-bake:
contexts:
base: target:image1_0
It will find the target and build fine
Expected behaviour
targets in compose files should be correctly identified even if they contain dots .
Actual behaviour
target cannot be found, unless the dots . are replaced with underscores _. This needs to happen in the x-bake.contexts only.
Buildx version
github.com/docker/buildx v0.23.0 28c90ea
Docker info
Client: Docker Engine - Community
Version: 28.1.1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.23.0
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.35.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 16
Server Version: 28.1.1
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
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
runc version: v1.2.5-0-g59923ef
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.6.87.2-microsoft-standard-WSL2
Operating System: Ubuntu 22.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.602GiB
Name: REDACTED
ID: REDACTED
Docker Root Dir: /var/lib/docker
Debug Mode: false
Username: REDACTED
Experimental: false
Live Restore Enabled: false
Builders list
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
default* docker
\_ default \_ default running v0.21.0 linux/amd64 (+4), linux/386
desktop-linux error
Cannot load builder desktop-linux: protocol not available
Configuration
---
services:
image1.0:
image: test:latest
build:
context: .
dockerfile: Dockerfile
image2.0:
image: test:dev
build:
context: ./2.0
dockerfile: Dockerfile
x-bake:
contexts:
base: target:image1.0
leads to
docker buildx bake -f compose.yaml --progress plain
#0 building with "default" instance using docker driver
#1 [internal] load local bake definitions
#1 reading compose.yaml 331B / 331B done
#1 DONE 0.0s
ERROR: failed to find target image1.0
underscores work:
---
services:
image1.0:
image: test:latest
build:
context: .
dockerfile: Dockerfile
image2.0:
image: test:dev
build:
context: ./2.0
dockerfile: Dockerfile
x-bake:
contexts:
base: target:image1_0
Build logs
Additional info
No response
Activity
yanwic commentedon Aug 8, 2025
might be related to #1009
crazy-max commentedon Aug 8, 2025
Named contexts are now supported in the compose spec: https://docs.docker.com/reference/compose-file/build/#additional_contexts so you can avoid
x-bake.Can you try with:
crazy-max commentedon Aug 8, 2025
But still needs a fix in
x-bake, will take look.yanwic commentedon Aug 8, 2025
I just tried with
additinal_contexts, but both variantsservice:image1.0andtarget:image1.0fail with:when using
service:image1_0it also fails buttarget:image1_0works in this case.yanwic commentedon Aug 8, 2025
I just noticed that, when printed out to JSON it shows all targets are converted to using underscores. This might be the root cause for this behaviour:
crazy-max commentedon Aug 8, 2025
Thanks for your feedback, I'm taking a look