Skip to content

Commit 76f7bf4

Browse files
committed
bake: make --load use oci exporter with moby containerd store
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 51b56a3 commit 76f7bf4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

commands/bake.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type bakeOptions struct {
3737

3838
func 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

Comments
 (0)