summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorSebastiaan van Stijn <thaJeztah@users.noreply.github.com>2022-08-18 20:14:47 +0200
committerGitHub <noreply@github.com>2022-08-18 20:14:47 +0200
commita4ac991d02868cc68ee0cf3b912baa3d51af96ee (patch)
tree7682a1affab8b2dc8683c50d0915787d53d953fb /api
parent5675d3a8fefb1ee646858bcc80a6bbb376486de3 (diff)
parent7b153b9e28b53779215de209736310f9266b3f2f (diff)
downloaddocker-a4ac991d02868cc68ee0cf3b912baa3d51af96ee.tar.gz
Merge pull request #43657 from thaJeztah/default_builder_version
api: set default "Builder-Version" to "2" (BuildKit) on Linux
Diffstat (limited to 'api')
-rw-r--r--api/server/router/build/build.go29
-rw-r--r--api/swagger.yaml12
2 files changed, 30 insertions, 11 deletions
diff --git a/api/server/router/build/build.go b/api/server/router/build/build.go
index 8ad89ac2b7..75ae8f0ada 100644
--- a/api/server/router/build/build.go
+++ b/api/server/router/build/build.go
@@ -1,6 +1,8 @@
package build // import "github.com/docker/docker/api/server/router/build"
import (
+ "runtime"
+
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/types"
)
@@ -37,17 +39,24 @@ func (r *buildRouter) initRoutes() {
}
}
-// BuilderVersion derives the default docker builder version from the config
-// Note: it is valid to have BuilderVersion unset which means it is up to the
-// client to choose which builder to use.
+// BuilderVersion derives the default docker builder version from the config.
+//
+// The default on Linux is version "2" (BuildKit), but the daemon can be
+// configured to recommend version "1" (classic Builder). Windows does not
+// yet support BuildKit for native Windows images, and uses "1" (classic builder)
+// as a default.
+//
+// This value is only a recommendation as advertised by the daemon, and it is
+// up to the client to choose which builder to use.
func BuilderVersion(features map[string]bool) types.BuilderVersion {
- var bv types.BuilderVersion
- if v, ok := features["buildkit"]; ok {
- if v {
- bv = types.BuilderBuildKit
- } else {
- bv = types.BuilderV1
- }
+ // TODO(thaJeztah) move the default to daemon/config
+ if runtime.GOOS == "windows" {
+ return types.BuilderV1
+ }
+
+ bv := types.BuilderBuildKit
+ if v, ok := features["buildkit"]; ok && !v {
+ bv = types.BuilderV1
}
return bv
}
diff --git a/api/swagger.yaml b/api/swagger.yaml
index a53130a92a..181c80a418 100644
--- a/api/swagger.yaml
+++ b/api/swagger.yaml
@@ -8786,7 +8786,17 @@ paths:
description: "Max API Version the server supports"
Builder-Version:
type: "string"
- description: "Default version of docker image builder"
+ description: |
+ Default version of docker image builder
+
+ The default on Linux is version "2" (BuildKit), but the daemon
+ can be configured to recommend version "1" (classic Builder).
+ Windows does not yet support BuildKit for native Windows images,
+ and uses "1" (classic builder) as a default.
+
+ This value is a recommendation as advertised by the daemon, and
+ it is up to the client to choose which builder to use.
+ default: "2"
Docker-Experimental:
type: "boolean"
description: "If the server is running with experimental mode enabled"