From ef09ca898794c9d7cd2bf6ecc518d3abf972f5c4 Mon Sep 17 00:00:00 2001 From: Anda Xu Date: Mon, 6 Aug 2018 14:16:11 -0700 Subject: [PATCH] enable buildkit as builder from daemon; no env var needs to be set Signed-off-by: Anda Xu --- cli/command/cli.go | 2 ++ cli/command/image/build.go | 11 ++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 25aaf64b5c..9d169e6727 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -208,6 +208,7 @@ func (cli *DockerCli) initializeFromClient() { cli.serverInfo = ServerInfo{ HasExperimental: ping.Experimental, OSType: ping.OSType, + BuildkitEnabled: ping.Buildkit, } cli.client.NegotiateAPIVersionPing(ping) } @@ -241,6 +242,7 @@ func (cli *DockerCli) NewContainerizedEngineClient(sockPath string) (containeriz type ServerInfo struct { HasExperimental bool OSType string + BuildkitEnabled bool } // ClientInfo stores details about the supported features of the client diff --git a/cli/command/image/build.go b/cli/command/image/build.go index df67a7731f..8105341bfd 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -13,7 +13,6 @@ import ( "path/filepath" "regexp" "runtime" - "strconv" "strings" "github.com/docker/cli/cli" @@ -181,14 +180,8 @@ func (out *lastProgressOutput) WriteProgress(prog progress.Progress) error { // nolint: gocyclo func runBuild(dockerCli command.Cli, options buildOptions) error { - if buildkitEnv := os.Getenv("DOCKER_BUILDKIT"); buildkitEnv != "" { - enableBuildkit, err := strconv.ParseBool(buildkitEnv) - if err != nil { - return errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value") - } - if enableBuildkit { - return runBuildBuildKit(dockerCli, options) - } + if dockerCli.ServerInfo().BuildkitEnabled && dockerCli.ServerInfo().HasExperimental { + return runBuildBuildKit(dockerCli, options) } var (