Skip to content

Commit 9f5ce0d

Browse files
committed
build: clarify that Bake dockerfile path resolves relative to context
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.
1 parent 65f6728 commit 9f5ce0d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

content/manuals/build/bake/targets.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ $ docker buildx bake
5454
The properties you can set for a target closely resemble the CLI flags for
5555
`docker build`, with a few additional properties that are specific to Bake.
5656

57+
The `dockerfile` property specifies the path to the Dockerfile for a target.
58+
If you also set a `context`, the `dockerfile` path resolves relative to that
59+
context.
60+
61+
```hcl {title=docker-bake.hcl}
62+
target "default" {
63+
context = "app"
64+
# resolves to app/src/www/Dockerfile
65+
dockerfile = "src/www/Dockerfile"
66+
}
67+
```
68+
5769
For all the properties you can set for a target, see the [Bake reference](/build/bake/reference#target).
5870

5971
## Grouping targets
@@ -112,7 +124,7 @@ Supported patterns:
112124
> Always wrap wildcard patterns in quotes. Without quotes, your shell will expand the
113125
> wildcard to match files in the current directory, which usually causes errors.
114126
115-
Examples:
127+
Examples:
116128

117129
```console
118130
# Match all targets starting with 'foo-'
@@ -129,7 +141,7 @@ $ docker buildx bake "[fb]oo-bar"
129141

130142
# Matches: mtx-a-b-d, mtx-a-b-e, mtx-a-b-f
131143
$ docker buildx bake "mtx-a-b-*"
132-
```
144+
```
133145

134146
You can also combine multiple patterns:
135147

0 commit comments

Comments
 (0)