Skip to content

Commit

Permalink
Merge pull request moby#46605 from vvoland/c8d-load-compressed
Browse files Browse the repository at this point in the history
c8d/load: Handle compressed archives
  • Loading branch information
vvoland authored Oct 11, 2023
2 parents a67b755 + fcabc48 commit e78152a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion daemon/containerd/image_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/container"
"github.com/docker/docker/errdefs"
dockerarchive "github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/platforms"
"github.com/docker/docker/pkg/streamformatter"
"github.com/opencontainers/image-spec/specs-go"
Expand Down Expand Up @@ -148,6 +149,12 @@ func leaseContent(ctx context.Context, store content.Store, leasesManager leases
// complement of ExportImage. The input stream is an uncompressed tar
// ball containing images and metadata.
func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
decompressed, err := dockerarchive.DecompressStream(inTar)
if err != nil {
return errors.Wrap(err, "failed to decompress input tar archive")
}
defer decompressed.Close()

opts := []containerd.ImportOpt{
// TODO(vvoland): Allow user to pass platform
containerd.WithImportPlatform(cplatforms.All),
Expand All @@ -164,7 +171,7 @@ func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outSt
}),
}

imgs, err := i.client.Import(ctx, inTar, opts...)
imgs, err := i.client.Import(ctx, decompressed, opts...)
if err != nil {
log.G(ctx).WithError(err).Debug("failed to import image to containerd")
return errdefs.System(err)
Expand Down

0 comments on commit e78152a

Please sign in to comment.