From 164bb43cf4ea666b979a21f2a4b2f8ed5682b88f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 13 Jun 2025 18:49:50 +0200 Subject: [PATCH 1/7] remove "experimental" hint from help / usage output This was added in 02c2073feb3681e5c13e944d5f1cd2246cc22013, which changed the buildx CLI to match the behavior of the docker CLI, which conditionally hid some options that were marked experimental. The CLI now shows has client-side experimental options enabled by default (but labeled as experimental where suitable). Before this patch, every command would print this message unless experimental was enabled; docker buildx --help ... Run 'docker buildx COMMAND --help' for more information on a command. Experimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them. With this patch applied, that message is no longer shown. Signed-off-by: Sebastiaan van Stijn --- commands/root.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/commands/root.go b/commands/root.go index 654e89e4bff4..f07bf17c4a4d 100644 --- a/commands/root.go +++ b/commands/root.go @@ -84,10 +84,6 @@ func NewRootCmd(name string, isPlugin bool, dockerCli *command.DockerCli) *cobra "using default config store", )) - if !confutil.IsExperimental() { - cmd.SetHelpTemplate(cmd.HelpTemplate() + "\nExperimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.\n") - } - addCommands(cmd, &opt, dockerCli) return cmd } From baf1b1e55eb9d4fedabf894b872d63df6291d6d1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Jul 2025 12:32:59 +0200 Subject: [PATCH 2/7] commands: enable experimental commands by default Experimental commands are labeled as experimental, but we can enable them by default to encourage users to try them. Signed-off-by: Sebastiaan van Stijn --- commands/root.go | 11 +++++------ docs/debugging.md | 7 ------- docs/reference/buildx_build.md | 3 --- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/commands/root.go b/commands/root.go index f07bf17c4a4d..ca8cafb4a577 100644 --- a/commands/root.go +++ b/commands/root.go @@ -7,7 +7,6 @@ import ( historycmd "github.com/docker/buildx/commands/history" imagetoolscmd "github.com/docker/buildx/commands/imagetools" "github.com/docker/buildx/util/cobrautil/completion" - "github.com/docker/buildx/util/confutil" "github.com/docker/buildx/util/logutil" "github.com/docker/cli-docs-tool/annotation" "github.com/docker/cli/cli" @@ -113,13 +112,13 @@ func addCommands(cmd *cobra.Command, opts *rootOptions, dockerCli command.Cli) { duCmd(dockerCli, opts), imagetoolscmd.RootCmd(cmd, dockerCli, imagetoolscmd.RootOptions{Builder: &opts.builder}), historycmd.RootCmd(cmd, dockerCli, historycmd.RootOptions{Builder: &opts.builder}), + + // experimental commands + debugCmd(dockerCli, opts), + dapCmd(dockerCli, opts), ) - if confutil.IsExperimental() { - cmd.AddCommand(debugCmd(dockerCli, opts)) - cmd.AddCommand(dapCmd(dockerCli, opts)) - } - cmd.RegisterFlagCompletionFunc( //nolint:errcheck + _ = cmd.RegisterFlagCompletionFunc( "builder", completion.BuilderNames(dockerCli), ) diff --git a/docs/debugging.md b/docs/debugging.md index 8e3662f3fb46..12acef8f23ea 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -11,13 +11,6 @@ state of the build environment at any point. ## Starting the debugger -To start the debugger, first, ensure that `BUILDX_EXPERIMENTAL=1` is set in -your environment. - -```console -$ export BUILDX_EXPERIMENTAL=1 -``` - To start a debug session for a build, you can use the `buildx debug` command with `--invoke` flag to specify a command to launch in the resulting image. `buildx debug` command provides `buildx debug build` subcommand that provides the same features as the normal `buildx build` command but allows launching the debugger session after the build. diff --git a/docs/reference/buildx_build.md b/docs/reference/buildx_build.md index dd320cc8f114..5fc5cbf26255 100644 --- a/docs/reference/buildx_build.md +++ b/docs/reference/buildx_build.md @@ -54,9 +54,6 @@ Start a build -Flags marked with `[experimental]` need to be explicitly enabled by setting the -`BUILDX_EXPERIMENTAL=1` environment variable. - ## Description The `docker buildx build` command starts a build using BuildKit. From 74da0d67647368d8a5ca9083ac5089be5bac71f5 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Jul 2025 12:41:27 +0200 Subject: [PATCH 3/7] remove uses of BUILDX_EXPERIMENTAL for generating docs As the experimental commands are enabled by default now, there's no need to set this env-var for generating the docs. Signed-off-by: Sebastiaan van Stijn --- docker-bake.hcl | 2 -- hack/dockerfiles/docs.Dockerfile | 1 - 2 files changed, 3 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 038e191bd382..b59612038d4c 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -91,7 +91,6 @@ target "validate-docs" { inherits = ["_common"] args = { FORMATS = DOCS_FORMATS - BUILDX_EXPERIMENTAL = 1 // enables experimental cmds/flags for docs generation } dockerfile = "./hack/dockerfiles/docs.Dockerfile" target = "validate" @@ -116,7 +115,6 @@ target "update-docs" { inherits = ["_common"] args = { FORMATS = DOCS_FORMATS - BUILDX_EXPERIMENTAL = 1 // enables experimental cmds/flags for docs generation } dockerfile = "./hack/dockerfiles/docs.Dockerfile" target = "update" diff --git a/hack/dockerfiles/docs.Dockerfile b/hack/dockerfiles/docs.Dockerfile index 13cfb028c82a..2a0a8e1af330 100644 --- a/hack/dockerfiles/docs.Dockerfile +++ b/hack/dockerfiles/docs.Dockerfile @@ -16,7 +16,6 @@ RUN apk add --no-cache rsync git WORKDIR /src COPY --from=docsgen /out/docsgen /usr/bin ARG FORMATS -ARG BUILDX_EXPERIMENTAL RUN --mount=target=/context \ --mount=target=.,type=tmpfs < Date: Thu, 3 Jul 2025 12:43:54 +0200 Subject: [PATCH 4/7] util/confutil: remove IsExperimental() utility This function is no longer used, and does not have external consumers; https://grep.app/search?f.lang=Go&q=.IsExperimental%28%29 Signed-off-by: Sebastiaan van Stijn --- util/confutil/exp.go | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 util/confutil/exp.go diff --git a/util/confutil/exp.go b/util/confutil/exp.go deleted file mode 100644 index 03c6b97a6480..000000000000 --- a/util/confutil/exp.go +++ /dev/null @@ -1,15 +0,0 @@ -package confutil - -import ( - "os" - "strconv" -) - -// IsExperimental checks if the experimental flag has been configured. -func IsExperimental() bool { - if v, ok := os.LookupEnv("BUILDX_EXPERIMENTAL"); ok { - vv, _ := strconv.ParseBool(v) - return vv - } - return false -} From 9691c0179a56b0e90482aab9c9a5a138fc8e8bdd Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Jul 2025 12:54:15 +0200 Subject: [PATCH 5/7] tests: remove redundant cleanup t.TempDir() already cleans up after the test. Signed-off-by: Sebastiaan van Stijn --- tests/integration.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/integration.go b/tests/integration.go index 574672a7ee79..0d2ed5d5fbe5 100644 --- a/tests/integration.go +++ b/tests/integration.go @@ -172,9 +172,6 @@ func buildkitVersion(t *testing.T, sb integration.Sandbox) string { require.NoError(t, err, "undock not found") destDir := t.TempDir() - t.Cleanup(func() { - os.RemoveAll(destDir) - }) cmd := exec.Command(undockBin, "--cachedir", "/root/.cache/undock", "--include", "/usr/bin/buildkitd", "--rm-dist", buildkitImage, destDir) require.NoErrorf(t, cmd.Run(), "failed to extract buildkitd binary from %q", buildkitImage) From 5f704ad0894acc7c49237023cdc7755815ac1cd4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Jul 2025 12:55:35 +0200 Subject: [PATCH 6/7] remove "experimental" integration tests Experimental commands are now enabled by default, so there should not be a need to run tests separately. Signed-off-by: Sebastiaan van Stijn --- .github/workflows/build.yml | 24 ------------------------ hack/test | 2 -- tests/integration.go | 12 ------------ 3 files changed, 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a43d82344da7..7bc8120aab16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,40 +62,19 @@ jobs: - remote pkg: - ./tests - mode: - - "" - - experimental include: - worker: docker pkg: ./tests - worker: docker+containerd # same as docker, but with containerd snapshotter pkg: ./tests - - worker: docker - pkg: ./tests - mode: experimental - - worker: docker+containerd # same as docker, but with containerd snapshotter - pkg: ./tests - mode: experimental - worker: "docker@27.5" pkg: ./tests - worker: "docker+containerd@27.5" # same as docker, but with containerd snapshotter pkg: ./tests - - worker: "docker@27.5" - pkg: ./tests - mode: experimental - - worker: "docker+containerd@27.5" # same as docker, but with containerd snapshotter - pkg: ./tests - mode: experimental - - worker: "docker@26.1" - pkg: ./tests - - worker: "docker+containerd@26.1" # same as docker, but with containerd snapshotter - pkg: ./tests - worker: "docker@26.1" pkg: ./tests - mode: experimental - worker: "docker+containerd@26.1" # same as docker, but with containerd snapshotter pkg: ./tests - mode: experimental steps: - name: Prepare @@ -116,9 +95,6 @@ jobs: if [[ "${{ matrix.worker }}" == "docker"* ]]; then echo "TEST_DOCKERD=1" >> $GITHUB_ENV fi - if [ "${{ matrix.mode }}" = "experimental" ]; then - echo "TEST_BUILDX_EXPERIMENTAL=1" >> $GITHUB_ENV - fi - name: Checkout uses: actions/checkout@v4 diff --git a/hack/test b/hack/test index 3aa3ec00fb85..4369dc019af9 100755 --- a/hack/test +++ b/hack/test @@ -15,7 +15,6 @@ set -eu -o pipefail : "${TEST_DOCKERD=}" : "${TEST_BUILDKIT_TAG=}" : "${TEST_BUILDKIT_IMAGE=}" -: "${TEST_BUILDX_EXPERIMENTAL=}" if [ "$TEST_IMAGE_BUILD" = "1" ]; then ${BUILDX_CMD} bake integration-test --set "*.output=type=docker,name=$TEST_IMAGE_ID" @@ -54,7 +53,6 @@ cid=$(docker create --rm --privileged $dockerConfigMount \ -e TEST_DOCKERD \ -e TEST_BUILDKIT_IMAGE \ -e TEST_BUILDKIT_TAG \ - -e TEST_BUILDX_EXPERIMENTAL \ -e SKIP_INTEGRATION_TESTS \ -e GOTESTSUM_FORMAT \ -e GO_TEST_COVERPROFILE \ diff --git a/tests/integration.go b/tests/integration.go index 0d2ed5d5fbe5..673bb04da974 100644 --- a/tests/integration.go +++ b/tests/integration.go @@ -5,7 +5,6 @@ import ( "os/exec" "path/filepath" "reflect" - "strconv" "strings" "sync" "testing" @@ -64,9 +63,6 @@ func buildxCmd(sb integration.Sandbox, opts ...cmdOpt) *exec.Cmd { if context := sb.DockerAddress(); context != "" { cmd.Env = append(cmd.Env, "DOCKER_CONTEXT="+context) } - if isExperimental() { - cmd.Env = append(cmd.Env, "BUILDX_EXPERIMENTAL=1") - } if v := os.Getenv("GO_TEST_COVERPROFILE"); v != "" { coverDir := filepath.Join(filepath.Dir(v), "helpers") cmd.Env = append(cmd.Env, "GOCOVERDIR="+coverDir) @@ -128,14 +124,6 @@ func driverName(sbName string) (string, bool, bool) { return name, hasVersion, hasFeature } -func isExperimental() bool { - if v, ok := os.LookupEnv("TEST_BUILDX_EXPERIMENTAL"); ok { - vv, _ := strconv.ParseBool(v) - return vv - } - return false -} - func buildkitTag() string { if v := os.Getenv("TEST_BUILDKIT_TAG"); v != "" { return v From 484ab1b03a172c94d8b27283f6cec67b835e531f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Jul 2025 12:59:58 +0200 Subject: [PATCH 7/7] docs: remove use of BUILDX_EXPERIMENTAL as example It was only used to illustrate the concept, so let's use something generic. Signed-off-by: Sebastiaan van Stijn --- docs/bake-reference.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/bake-reference.md b/docs/bake-reference.md index af8cddfc74a7..1bb396a8a48a 100644 --- a/docs/bake-reference.md +++ b/docs/bake-reference.md @@ -632,7 +632,7 @@ from both the `app-dev` and `_release` targets. target "app-dev" { args = { GO_VERSION = "1.20" - BUILDX_EXPERIMENTAL = 1 + ENABLE_DEBUG = 1 } tags = ["docker.io/username/myapp"] dockerfile = "app.Dockerfile" @@ -644,7 +644,7 @@ target "app-dev" { target "_release" { args = { BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1 - BUILDX_EXPERIMENTAL = 0 + ENABLE_DEBUG = 0 } } @@ -656,7 +656,7 @@ target "app-release" { When inheriting attributes from multiple targets and there's a conflict, the target that appears last in the `inherits` list takes precedence. -The previous example defines the `BUILDX_EXPERIMENTAL` argument twice for the `app-release` target. +The previous example defines the `ENABLE_DEBUG` argument twice for the `app-release` target. It resolves to `0` because the `_release` target appears last in the inheritance chain: ```console @@ -676,7 +676,7 @@ $ docker buildx bake --print app-release "dockerfile": "app.Dockerfile", "args": { "BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1", - "BUILDX_EXPERIMENTAL": "0", + "ENABLE_DEBUG": "0", "GO_VERSION": "1.20" }, "labels": {