|
@@ -16,7 +16,6 @@ import (
|
|
|
cerrdefs "github.com/containerd/containerd/errdefs"
|
|
|
"github.com/containerd/containerd/images"
|
|
|
"github.com/containerd/containerd/leases"
|
|
|
- "github.com/containerd/containerd/platforms"
|
|
|
"github.com/containerd/containerd/rootfs"
|
|
|
"github.com/containerd/containerd/snapshots"
|
|
|
"github.com/docker/docker/api/types/backend"
|
|
@@ -39,20 +38,19 @@ with adaptations to match the Moby data model and services.
|
|
|
// CommitImage creates a new image from a commit config.
|
|
|
func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig) (image.ID, error) {
|
|
|
container := i.containers.Get(cc.ContainerID)
|
|
|
+ cs := i.client.ContentStore()
|
|
|
|
|
|
- desc, err := i.resolveDescriptor(ctx, container.Config.Image)
|
|
|
+ imageManifestBytes, err := content.ReadBlob(ctx, cs, *container.ImageManifest)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
|
|
|
- cs := i.client.ContentStore()
|
|
|
-
|
|
|
- ocimanifest, err := images.Manifest(ctx, cs, desc, platforms.DefaultStrict())
|
|
|
- if err != nil {
|
|
|
+ var manifest ocispec.Manifest
|
|
|
+ if err := json.Unmarshal(imageManifestBytes, &manifest); err != nil {
|
|
|
return "", err
|
|
|
}
|
|
|
|
|
|
- imageConfigBytes, err := content.ReadBlob(ctx, cs, ocimanifest.Config)
|
|
|
+ imageConfigBytes, err := content.ReadBlob(ctx, cs, manifest.Config)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
@@ -88,7 +86,7 @@ func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig)
|
|
|
return "", fmt.Errorf("failed to apply diff: %w", err)
|
|
|
}
|
|
|
|
|
|
- layers := append(ocimanifest.Layers, diffLayerDesc)
|
|
|
+ layers := append(manifest.Layers, diffLayerDesc)
|
|
|
commitManifestDesc, configDigest, err := writeContentsForImage(ctx, i.snapshotter, cs, imageConfig, layers)
|
|
|
if err != nil {
|
|
|
return "", err
|
|
@@ -96,7 +94,7 @@ func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig)
|
|
|
|
|
|
// image create
|
|
|
img := images.Image{
|
|
|
- Name: configDigest.String(),
|
|
|
+ Name: danglingImageName(configDigest.Digest()),
|
|
|
Target: commitManifestDesc,
|
|
|
CreatedAt: time.Now(),
|
|
|
}
|