diff --git a/cmd/docker/builder.go b/cmd/docker/builder.go index bc3db2066cf3..31c6076046c0 100644 --- a/cmd/docker/builder.go +++ b/cmd/docker/builder.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "os" + "strconv" pluginmanager "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/cli/command" @@ -39,16 +41,19 @@ func newBuilderError(warn bool, err error) error { } func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []string) ([]string, []string, error) { - var useLegacy bool - var useBuilder bool + var useLegacy, useBuilder bool - if bkExplicit, err := command.DockerBuildKitEnabled(); err != nil { - return nil, nil, err - } else if bkExplicit != nil { - if *bkExplicit { - useBuilder = true - } else { + // check DOCKER_BUILDKIT env var is present and + // if not assume we want to use the builder component + if v, ok := os.LookupEnv("DOCKER_BUILDKIT"); ok { + enabled, err := strconv.ParseBool(v) + if err != nil { + return args, osargs, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value") + } + if !enabled { useLegacy = true + } else { + useBuilder = true } } @@ -67,6 +72,12 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st return args, osargs, nil } + // wcow build command must use the legacy builder + // if not opt-in through a builder component + if !useBuilder && dockerCli.ServerInfo().OSType == "windows" { + return args, osargs, nil + } + if useLegacy { // display warning if not wcow and continue if dockerCli.ServerInfo().OSType != "windows" {