@@ -29,6 +29,10 @@ const (
2929 buildxMissingError = `ERROR: BuildKit is enabled but the buildx component is missing or broken.
3030 Install the buildx component to build images with BuildKit:
3131 https://docs.docker.com/go/buildx/`
32+
33+ bakeMissingError = `ERROR: docker bake requires the buildx component but it is missing or broken.
34+ Install the buildx component to use bake:
35+ https://docs.docker.com/go/buildx/`
3236)
3337
3438func newBuilderError (errorMsg string , pluginLoadErr error ) error {
@@ -59,6 +63,10 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
5963 useBuilder = true
6064 }
6165 }
66+ // docker bake always requires buildkit; ignore "DOCKER_BUILDKIT=0".
67+ if buildKitDisabled && len (args ) > 0 && args [0 ] == "bake" {
68+ buildKitDisabled = false
69+ }
6270
6371 // if a builder alias is defined, use it instead
6472 // of the default one
@@ -105,6 +113,10 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
105113 perr = plugin .Err
106114 }
107115 if perr != nil {
116+ // Using bake without buildx installed is always an error.
117+ if len (args ) > 0 && args [0 ] == "bake" {
118+ return args , osargs , nil , newBuilderError (bakeMissingError , perr )
119+ }
108120 // if builder is enforced with DOCKER_BUILDKIT=1, cmd must fail
109121 // if the plugin is missing or broken.
110122 if useBuilder {
@@ -135,6 +147,11 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
135147
136148func forwardBuilder (alias string , args , osargs []string ) ([]string , []string , []string , bool ) {
137149 aliases := [][3 ][]string {
150+ {
151+ {"bake" },
152+ {alias , "bake" },
153+ {},
154+ },
138155 {
139156 {"builder" },
140157 {alias },
0 commit comments