From 83d5132a03a9152767bc7aae713b1adfca3cd469 Mon Sep 17 00:00:00 2001 From: aevesdocker Date: Thu, 4 Sep 2025 15:32:48 +0100 Subject: [PATCH 1/2] bake: add pattern matching for targets input --- content/manuals/build/bake/targets.md | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/content/manuals/build/bake/targets.md b/content/manuals/build/bake/targets.md index 183eb939e92f..c6b01b2cd785 100644 --- a/content/manuals/build/bake/targets.md +++ b/content/manuals/build/bake/targets.md @@ -96,6 +96,42 @@ command. $ docker buildx bake all ``` +## Pattern matching for targets and groups + +Bake supports shell-style wildcard patterns when specifying target or grouped targets. +This makes it easier to build multiple targets without listing each one explicitly. + +Supported patterns: + +- `*` matches any sequence of characters +- `?` matches any single character +- `[abc]` matches any character in brackets + +Examples: + +```console +# Match all targets starting with 'foo-' +$ docker buildx bake foo-* + +# Match all targets +$ docker buildx bake * + +# Matches: foo-baz, foo-caz, foo-daz, etc. +$ docker buildx bake "foo-?az" + +# Matches: foo-bar, boo-bar +$ 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 patters: + +```console +$ docker buildx bake "*" "tests" +``` + ## Additional resources Refer to the following pages to learn more about Bake's features: From ed70bdc9b683fa4252d05e97230ab1966825bc2f Mon Sep 17 00:00:00 2001 From: aevesdocker Date: Mon, 8 Sep 2025 11:09:54 +0100 Subject: [PATCH 2/2] feedback --- content/manuals/build/bake/targets.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/content/manuals/build/bake/targets.md b/content/manuals/build/bake/targets.md index c6b01b2cd785..54dce0cf3ec4 100644 --- a/content/manuals/build/bake/targets.md +++ b/content/manuals/build/bake/targets.md @@ -107,14 +107,19 @@ Supported patterns: - `?` matches any single character - `[abc]` matches any character in brackets +> [!NOTE] +> +> 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: ```console # Match all targets starting with 'foo-' -$ docker buildx bake foo-* +$ docker buildx bake "foo-*" # Match all targets -$ docker buildx bake * +$ docker buildx bake "*" # Matches: foo-baz, foo-caz, foo-daz, etc. $ docker buildx bake "foo-?az" @@ -126,10 +131,10 @@ $ docker buildx bake "[fb]oo-bar" $ docker buildx bake "mtx-a-b-*" ``` -You can also combine multiple patters: +You can also combine multiple patterns: ```console -$ docker buildx bake "*" "tests" +$ docker buildx bake "foo*" "tests" ``` ## Additional resources