Skip to content

Repositories with no unique layers don't show up in _catalog #3172

@adamwg

Description

@adamwg

A repository can contain manifests, tags, etc. without having any unique layers, if all the images it contains use layers shared with some other repository. For example, if I do the following:

docker tag alpine:3 registry.example.com/other-repo:latest
docker push registry.example.com/other-repo:latest
docker tag alpine:3 registry.example.com/alpine:3
docker push registry.example.com/alpine:3

then the storage for registry.example.com will have the following contents:

docker/registry/v2/blobs/sha256/c9/c9b1b535fdd91a9855fb7f82348177e5f019329a58c53c47272962dd60f71fc9/data
docker/registry/v2/blobs/sha256/dd/ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45/data
docker/registry/v2/blobs/sha256/e7/e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a/data
docker/registry/v2/repositories/alpine/_manifests/revisions/sha256/ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45/link
docker/registry/v2/repositories/alpine/_manifests/tags/3/current/link
docker/registry/v2/repositories/alpine/_manifests/tags/3/index/sha256/ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45/link
docker/registry/v2/repositories/other-repo/_layers/sha256/c9b1b535fdd91a9855fb7f82348177e5f019329a58c53c47272962dd60f71fc9/link
docker/registry/v2/repositories/other-repo/_layers/sha256/e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a/link
docker/registry/v2/repositories/other-repo/_manifests/revisions/sha256/ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45/link
docker/registry/v2/repositories/other-repo/_manifests/tags/latest/current/link
docker/registry/v2/repositories/other-repo/_manifests/tags/latest/index/sha256/ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45/link

Note that there's no _layers directory under alpine since all its layers are contained in other-repo.

Because of the way _catalog is implemented in distribution, this means alpine won't show up in the _catalog response.

It seems like an easy fix for this would be to use _manifests rather than _layers as the indicator that a directory is a repository. I've tried this and it appears to work fine. Would this cause any problems? If not, I'll submit a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions