Skip to content

Commit ef09ca8

Browse files
committed
enable buildkit as builder from daemon; no env var needs to be set
Signed-off-by: Anda Xu <anda.xu@docker.com>
1 parent 466e1b0 commit ef09ca8

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

cli/command/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (cli *DockerCli) initializeFromClient() {
208208
cli.serverInfo = ServerInfo{
209209
HasExperimental: ping.Experimental,
210210
OSType: ping.OSType,
211+
BuildkitEnabled: ping.Buildkit,
211212
}
212213
cli.client.NegotiateAPIVersionPing(ping)
213214
}
@@ -241,6 +242,7 @@ func (cli *DockerCli) NewContainerizedEngineClient(sockPath string) (containeriz
241242
type ServerInfo struct {
242243
HasExperimental bool
243244
OSType string
245+
BuildkitEnabled bool
244246
}
245247

246248
// ClientInfo stores details about the supported features of the client

cli/command/image/build.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"path/filepath"
1414
"regexp"
1515
"runtime"
16-
"strconv"
1716
"strings"
1817

1918
"github.com/docker/cli/cli"
@@ -181,14 +180,8 @@ func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error {
181180

182181
// nolint: gocyclo
183182
func runBuild(dockerCli command.Cli, options buildOptions) error {
184-
if buildkitEnv := os.Getenv("DOCKER_BUILDKIT"); buildkitEnv != "" {
185-
enableBuildkit, err := strconv.ParseBool(buildkitEnv)
186-
if err != nil {
187-
return errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value")
188-
}
189-
if enableBuildkit {
190-
return runBuildBuildKit(dockerCli, options)
191-
}
183+
if dockerCli.ServerInfo().BuildkitEnabled && dockerCli.ServerInfo().HasExperimental {
184+
return runBuildBuildKit(dockerCli, options)
192185
}
193186

194187
var (

0 commit comments

Comments
 (0)