-
Notifications
You must be signed in to change notification settings - Fork 619
Open
Labels
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
docker buildx bake seems to handle additional contexts differently, depending on whether the build context is a remote git context or a local context.
Using the configuration below (or use https://github.com/codello/buildx-bake-test) run the following commands:
# Local Build Context
docker buildx bake --set '*.tags=local/test'
# Git Build Context
docker buildx bake "https://github.com/codello/buildx-bake-test.git" --set '*.tags=remote/test'
# Lists the contents of the additional context
docker run local/test
docker run remote/testExpected behaviour
# Show results for local context
$ docker run local/test
.
└── file.txt
0 directories, 1 files
# Show results for git context
$ docker run remote/test
.
└── file.txt
0 directories, 1 filesActual behaviour
# Show results for local context
$ docker run local/test
.
└── file.txt
0 directories, 1 files
# Show results for git context
$ docker run remote/test
.
└── context
└── file.txt
1 directories, 1 filesBuildx version
github.com/docker/buildx v0.31.1 Homebrew
Docker info
Client: Docker Engine - Community
Version: 29.2.1
Context: colima
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.31.1
Path: /opt/homebrew/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 5.0.2
Path: /opt/homebrew/lib/docker/cli-plugins/docker-compose
Server:
Containers: 17
Running: 4
Paused: 0
Stopped: 13
Images: 38
Server Version: 28.4.0
Storage Driver: overlayfs
driver-type: io.containerd.snapshotter.v1
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: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
runc version: v1.2.5-0-g59923ef
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.8.0-64-generic
Operating System: Ubuntu 24.04.2 LTS
OSType: linux
Architecture: aarch64
CPUs: 2
Total Memory: 7.738GiB
Name: colima
ID: b157a974-1f7c-434c-a4ac-643b0d0ad581
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false
Firewall Backend: iptables
Builders list
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
colima* docker
\_ colima \_ colima running v0.24.0 linux/arm64
default docker
\_ default \_ default running v0.24.0 linux/arm64
Configuration
Directory layout (also currently available at https://github.com/codello/buildx-bake-test)
.
├── build/
│ └── Dockerfile
├── context/
│ └── file.txt (content irrelevant, can be empty)
└── docker-bake.hcl
FROM alpine
WORKDIR /test
COPY --from=context . .
ENTRYPOINT [ "tree" ]target "default" {
tags = ["local/test"]
output = [{ type = "docker" }]
contexts = {
context = "./context/"
}
context = "./build"
dockerfile = "Dockerfile"
}Invoked Commands:
# Local Build Context
docker buildx bake --set '*.tags=local/test'
# Git Build Context
docker buildx bake "https://github.com/codello/buildx-bake-test.git" --set '*.tags=remote/test'
# Lists the contents of the additional context
docker run local/test
docker run remote/testBuild logs
$ docker buildx bake --set '*.tags=local/test' --no-cache
[+] Building 1.1s (10/10) FINISHED docker:colima
=> [internal] load local bake definitions 0.0s
=> => reading docker-bake.hcl 180B / 180B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 112B 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.8s
=> [context context] load .dockerignore 0.0s
=> => transferring _context: 2B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [stage-0 1/3] FROM docker.io/library/alpine:latest@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659 0.0s
=> => resolve docker.io/library/alpine:latest@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659 0.0s
=> [context context] load from client 0.0s
=> => transferring _context: 27B 0.0s
=> CACHED [stage-0 2/3] WORKDIR /test 0.0s
=> [stage-0 3/3] COPY --from=context . . 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => exporting manifest sha256:e0c8b415385dbea953b3138efa689285566e1cc755a6f881eead49ce8e1333bf 0.0s
=> => exporting config sha256:8f1b96ea3473ddd7043d5f830be87c9b1d314a74cc1b0a358f25692dc284549f 0.0s
=> => exporting attestation manifest sha256:f71d4ad1a739e7fc28ed34114d96c49c870bfcb30dd0e71bb4bb8d80690d111c 0.0s
=> => exporting manifest list sha256:b85a127fb87ce3087ab769883fc0c3f1806a19275df71876c0934f206759e0c4 0.0s
=> => naming to docker.io/local/test:latest 0.0s
=> => unpacking to docker.io/local/test:latest 0.0s
$ docker buildx bake "https://github.com/codello/buildx-bake-test.git" --set '*.tags=remote/test' --no-cache
[+] Building 2.1s (8/8) FINISHED docker:colima
=> CACHED [internal] load git source https://github.com/codello/buildx-bake-test.git 1.7s
=> CACHED set context to build 0.0s
=> [internal] load metadata for docker.io/library/alpine:latest 0.2s
=> [stage-0 1/3] FROM docker.io/library/alpine:latest@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659 0.0s
=> => resolve docker.io/library/alpine:latest@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659 0.0s
=> CACHED set context context to ./context/ 0.0s
=> CACHED [stage-0 2/3] WORKDIR /test 0.0s
=> [stage-0 3/3] COPY --from=context . . 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => exporting manifest sha256:63980237cad096ade608a542e3a047d9a7d70a012860a268f8a9e93eabfbe424 0.0s
=> => exporting config sha256:f5d2e6112e5f7272557872bc4d3cddb58292cc2a68d2ca0815e41bedae16619b 0.0s
=> => exporting attestation manifest sha256:6809ceb536a33a4d8dae248c5332a6926d60678efe0ea4487013ee7b44614d32 0.0s
=> => exporting manifest list sha256:905bfa269e5d9f2fdb10b15a2a694f5ca3826b6edb20812b9b740734f6ab80f8 0.0s
=> => naming to docker.io/remote/test:latest 0.0s
=> => unpacking to docker.io/remote/test:latest 0.0s
Additional info
I have discovered this issue because a build in GitHub Actions couldn't find the expected files in an additional context. The workflow used a git context, so this issue doesn't seem to be related to my local configuration.
Reactions are currently unavailable