Top-level `docker bake` ignores the selected builder (`docker buildx use`) — builds on the context's docker driver instead of the current docker-container builder
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 50/100
Direzione di ricerca
Riproduci la discrepanza con un contesto Docker non predefinito e un builder docker-container selezionato, confrontando l’entry point di primo livello docker bake con docker buildx bake. Esamina quindi come la CLI inoltra l’alias di primo livello e come ciascun percorso risolve il builder corrente. Il lavoro è completato quando entrambi i comandi usano il builder selezionato in questa configurazione, oppure quando l’issue viene trasferita se l’inoltro appartiene a un’altra parte.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
Given a docker-container builder selected as the current builder (via docker buildx create --use / docker buildx use), the top-level docker bake <target> builds on the active docker context's implicit docker-driver builder, while docker buildx bake <target> builds on the selected docker-container builder. The two commands pick different builders from identical state.
Expected behaviour
Both docker bake and docker buildx bake should build with the builder that is currently selected — the one marked * in docker buildx ls and recorded in ~/.docker/buildx/current. docker bake reports Usage: docker buildx bake in its --help, so the two are expected to resolve the builder identically.
Actual behaviour
With a docker-container builder selected as current (confirmed by docker buildx ls and ~/.docker/buildx/current), and a non-default docker context active:
docker buildx bake app→#0 building with "repro-buildx" instance using docker-container driver✅docker bake app→#0 building with "repro-ctx" instance using docker driver❌ — falls back to the active context's implicit docker-driver builder, ignoring the selection.
This has real consequences: the docker-container driver supports cache exporters and features the docker driver does not, and tooling that acts on the selected builder (e.g. reproducible-containers/buildkit-cache-dance, which injects/extracts cache mounts against the selected builder) then silently operates on a different builder than the one docker bake actually used.
Buildx version
github.com/docker/buildx v0.35.0-desktop.2 b554ce1decd8b509893b1e7c6227eabfb923d094
Also reproduces on GitHub Actions with the upstream release github.com/docker/buildx v0.35.0 a319e5b15052cf6557ceb666eb8ff6e32380b782 (Docker 29.6.2, docker/setup-docker-action@v5 + docker/setup-buildx-action@v4).
Docker info
Client: Docker 29.6.2, Context: desktop-linux, buildx v0.35.0-desktop.2
Server:
Server Version: 29.6.2
Storage Driver: overlayfs (io.containerd.snapshotter.v1)
Cgroup Version: 2
containerd version: e53c7c1516c3b2bff98eb76f1f4117477e6f4e66
runc version: v1.3.6-0-g491b69ba
Kernel Version: 6.12.76-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 10 / Total Memory: 7.65GiB
(plugin list, labels and local paths trimmed)
Builders list
Current builder is the docker-container instance (*), yet docker bake used the repro-ctx docker driver:
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
repro-buildx* docker-container
\_ repro-buildx0 \_ repro-ctx inactive
default docker
\_ default \_ default running v0.31.2 linux/amd64 (+2), ...
desktop-linux docker
\_ desktop-linux \_ desktop-linux running v0.31.2 linux/amd64 (+2), ...
repro-ctx docker
\_ repro-ctx \_ repro-ctx running v0.31.2 linux/amd64 (+2), ...
$ cat ~/.docker/buildx/current
{"Key":"repro-ctx","Name":"repro-buildx","Global":false}
Configuration
Minimal reproduction (mirrors what docker/setup-docker-action — creates and uses a non-default context — and docker/setup-buildx-action --use do). The essential ingredients are a non-default active docker context plus a docker-container builder selected as current:
# Dockerfile
# syntax=docker/dockerfile:1
FROM alpine
RUN echo hello
# docker-bake.hcl
target "app" {
dockerfile = "Dockerfile"
}
# create + use a non-default context pointing at the same daemon
$ docker context create repro-ctx --docker host="$(docker context inspect $(docker context show) --format '{{.Endpoints.docker.Host}}')"
$ docker context use repro-ctx
# create a docker-container builder and select it
$ docker buildx create --name repro-buildx --driver docker-container --use
$ cat ~/.docker/buildx/current
{"Key":"repro-ctx","Name":"repro-buildx","Global":false} # docker-container builder is current
# same target, two commands, different builder:
$ docker bake app # -> #0 building with "repro-ctx" instance using docker driver (unexpected)
$ docker buildx bake app # -> #0 building with "repro-buildx" instance using docker-container driver (expected)
Build logs
# docker bake app
#0 building with "repro-ctx" instance using docker driver
# docker buildx bake app
#0 building with "repro-buildx" instance using docker-container driver
Additional info
~/.docker/buildx/currentcorrectly records thedocker-containerselection keyed to the active context, sodocker buildx use/--useitself works — only the top-leveldocker bakeentrypoint diverges.- The trigger requires a non-default active docker context whose implicit default is the
dockerdriver, plus adocker-containerbuilder selected as current. With the default context active, both commands agree. - Top-level
docker bake --helpprintsUsage: docker buildx bake, so it appears to route through buildx; the divergence seems to be in how the top-level command entrypoint resolves the current builder vs. thedocker buildx bakesubcommand path. (If the top-levelbakealias is registered/dispatched by docker/cli rather than buildx, this may need to be transferred there.)
- Lingua principale
- Go
- Stelle
- 6.1k
- Fork
- 2.2k
- Merge medio
- 1g 10h
- PR unite (30g)
- 47
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di docker/cli
-
kind/bug status/0-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
kind/bug status/0-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
kind/feature status/0-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
kind/bug status/0-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Issue simili
-
textual definition
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
geneontology/go-ontology#32653 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
needs design
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Priority/High ready-for-agent Severity/Major Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100