From 9f5ce0daee88e8157bdafca2f6d2397c84bc0ede Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 9 Mar 2026 13:50:27 +0100 Subject: [PATCH] build: clarify that Bake dockerfile path resolves relative to context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses #22199 — users were confused that the `dockerfile` property in a Bake target resolves relative to the `context` directory, not the working directory. Added an explicit note and example to the targets page. --- content/manuals/build/bake/targets.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/content/manuals/build/bake/targets.md b/content/manuals/build/bake/targets.md index 54dce0cf3e..03e6178ef7 100644 --- a/content/manuals/build/bake/targets.md +++ b/content/manuals/build/bake/targets.md @@ -54,6 +54,18 @@ $ docker buildx bake The properties you can set for a target closely resemble the CLI flags for `docker build`, with a few additional properties that are specific to Bake. +The `dockerfile` property specifies the path to the Dockerfile for a target. +If you also set a `context`, the `dockerfile` path resolves relative to that +context. + +```hcl {title=docker-bake.hcl} +target "default" { + context = "app" + # resolves to app/src/www/Dockerfile + dockerfile = "src/www/Dockerfile" +} +``` + For all the properties you can set for a target, see the [Bake reference](/build/bake/reference#target). ## Grouping targets @@ -112,7 +124,7 @@ Supported patterns: > Always wrap wildcard patterns in quotes. Without quotes, your shell will expand the > wildcard to match files in the current directory, which usually causes errors. -Examples: +Examples: ```console # Match all targets starting with 'foo-' @@ -129,7 +141,7 @@ $ docker buildx bake "[fb]oo-bar" # Matches: mtx-a-b-d, mtx-a-b-e, mtx-a-b-f $ docker buildx bake "mtx-a-b-*" -``` +``` You can also combine multiple patterns: