Skip to content

Commit 167c4fa

Browse files
authored
bake: add pattern matching for targets input (#23360)
<!--Delete sections as needed --> ## Description Adds docker/buildx#3280 ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent 5d28e19 commit 167c4fa

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

content/manuals/build/bake/targets.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,47 @@ command.
9696
$ docker buildx bake all
9797
```
9898

99+
## Pattern matching for targets and groups
100+
101+
Bake supports shell-style wildcard patterns when specifying target or grouped targets.
102+
This makes it easier to build multiple targets without listing each one explicitly.
103+
104+
Supported patterns:
105+
106+
- `*` matches any sequence of characters
107+
- `?` matches any single character
108+
- `[abc]` matches any character in brackets
109+
110+
> [!NOTE]
111+
>
112+
> Always wrap wildcard patterns in quotes. Without quotes, your shell will expand the
113+
> wildcard to match files in the current directory, which usually causes errors.
114+
115+
Examples:
116+
117+
```console
118+
# Match all targets starting with 'foo-'
119+
$ docker buildx bake "foo-*"
120+
121+
# Match all targets
122+
$ docker buildx bake "*"
123+
124+
# Matches: foo-baz, foo-caz, foo-daz, etc.
125+
$ docker buildx bake "foo-?az"
126+
127+
# Matches: foo-bar, boo-bar
128+
$ docker buildx bake "[fb]oo-bar"
129+
130+
# Matches: mtx-a-b-d, mtx-a-b-e, mtx-a-b-f
131+
$ docker buildx bake "mtx-a-b-*"
132+
```
133+
134+
You can also combine multiple patterns:
135+
136+
```console
137+
$ docker buildx bake "foo*" "tests"
138+
```
139+
99140
## Additional resources
100141

101142
Refer to the following pages to learn more about Bake's features:

0 commit comments

Comments
 (0)