Search code examples
dockerdocker-registry

Bash command to list all docker images in a remote registry


I have a program setup to remotely manage images & containers on various PCs on a local network. I'd like to be able to get a list of all images available on a registry as well. I have the IP of the registry machine and am looking for some command to list everything in that registry so I could sort by repository/tag.

Thanks for any help.


Solution

  • I suppose that you use latest v2 docker registry.

    Docker Registry v2 has a well defined REST API .

    For example, if you have a registry at location: registry.example.com:5000 and https proxy, you could use address: https://registry.example.com:5000/v2/_catalog to list all repositories.

    Here is an example of listing first 100 repositories and its tags in registry. Note that pagination of repositories and tags needs to be done more carefully than in this quick example.

    registry="registry.example.com:5000"
    repos=`curl https://$registry/v2/_catalog?n=100 | jq '.repositories[]' | tr -d '"'`
    for repo in $repos; do 
       curl https://$registry/v2/$repo/tags/list; 
    done