@@ -37,6 +37,7 @@ type bakeOptions struct {
3737
3838func runBake (dockerCli command.Cli , targets []string , in bakeOptions , cFlags commonFlags ) (err error ) {
3939 ctx := appcontext .Context ()
40+ docker := dockerutil .NewClient (dockerCli )
4041
4142 ctx , end , err := tracing .TraceCurrentCommand (ctx , "bake" )
4243 if err != nil {
@@ -73,7 +74,15 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
7374 }
7475 overrides = append (overrides , "*.push=true" )
7576 } else if in .exportLoad {
76- overrides = append (overrides , "*.output=type=docker" )
77+ dockerFeatures , err := docker .Features (ctx , "" )
78+ if err != nil {
79+ return err
80+ }
81+ if dockerFeatures [dockerutil .OCIImporter ] {
82+ overrides = append (overrides , "*.output=type=oci" )
83+ } else {
84+ overrides = append (overrides , "*.output=type=docker" )
85+ }
7786 }
7887 if cFlags .noCache != nil {
7988 overrides = append (overrides , fmt .Sprintf ("*.no-cache=%t" , * cFlags .noCache ))
@@ -191,7 +200,7 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
191200 return nil
192201 }
193202
194- resp , err := build .Build (ctx , nodes , bo , dockerutil . NewClient ( dockerCli ) , confutil .ConfigDir (dockerCli ), printer )
203+ resp , err := build .Build (ctx , nodes , bo , docker , confutil .ConfigDir (dockerCli ), printer )
195204 if err != nil {
196205 return wrapBuildError (err , true )
197206 }
0 commit comments