diff --git a/daemon/containerd/image_push.go b/daemon/containerd/image_push.go index 77323e35ce..7aac4345b3 100644 --- a/daemon/containerd/image_push.go +++ b/daemon/containerd/image_push.go @@ -73,7 +73,7 @@ func (i *ImageService) PushImage(ctx context.Context, targetRef reference.Named, var limiter *semaphore.Weighted = nil // TODO: Respect max concurrent downloads/uploads - mountableBlobs, err := i.findMissingMountable(ctx, store, jobs, target, targetRef, limiter) + mountableBlobs, err := findMissingMountable(ctx, store, jobs, target, targetRef, limiter) if err != nil { return err } @@ -146,7 +146,7 @@ func (i *ImageService) PushImage(ctx context.Context, targetRef reference.Named, // findMissingMountable will walk the target descriptor recursively and return // missing contents with their distribution source which could potentially // be cross-repo mounted. -func (i *ImageService) findMissingMountable(ctx context.Context, store content.Store, jobs *jobs, +func findMissingMountable(ctx context.Context, store content.Store, jobs *jobs, target ocispec.Descriptor, targetRef reference.Named, limiter *semaphore.Weighted, ) (map[digest.Digest]distributionSource, error) { mountableBlobs := map[digest.Digest]distributionSource{} @@ -169,7 +169,7 @@ func (i *ImageService) findMissingMountable(ctx context.Context, store content.S } for _, source := range sources { - if canBeMounted(desc.MediaType, targetRef, i.registryService.IsInsecureRegistry, source) { + if canBeMounted(desc.MediaType, targetRef, source) { mutex.Lock() mountableBlobs[desc.Digest] = source mutex.Unlock() @@ -252,7 +252,7 @@ func (source distributionSource) GetReference(dgst digest.Digest) (reference.Nam // canBeMounted returns if the content with given media type can be cross-repo // mounted when pushing it to a remote reference ref. -func canBeMounted(mediaType string, targetRef reference.Named, isInsecureFunc func(string) bool, source distributionSource) bool { +func canBeMounted(mediaType string, targetRef reference.Named, source distributionSource) bool { if containerdimages.IsManifestType(mediaType) { return false } @@ -261,11 +261,10 @@ func canBeMounted(mediaType string, targetRef reference.Named, isInsecureFunc fu } reg := reference.Domain(targetRef) - - // Cross-repo mount doesn't seem to work with insecure registries. - isInsecure := isInsecureFunc(reg) - if isInsecure { - return false + // Remove :port suffix from domain + // containerd distribution source label doesn't store port + if portIdx := strings.LastIndex(reg, ":"); portIdx != -1 { + reg = reg[:portIdx] } // If the source registry is the same as the one we are pushing to