Bash command to list all docker images in a remote registry
Asked Answered
D

2

7

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.

Drummond answered 8/3, 2016 at 15:9 Comment(0)
G
10

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
Guffaw answered 8/3, 2016 at 16:35 Comment(2)
Sorry for late response, I get curl: (77) error setting certificate verify locations I know the locations don't exist but as to why, I have no clue. I unfortunately don't have any knowledge in this type of thing. If I run curl with -k, I get curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol Any ideas on how to proceed? I feel as though this isn't enough information for you to really do anything.Drummond
Turned out I didn't need https:// in front of this. I could just do localhost:5000/v2/_catalog?n=100 and it worked. Hope this might help somebody.Drummond
P
3

While not a direct answer to find a list of images, you can list a specific image details with docker manifest inspect This was helpful for me finding if the image already existed or not. https://docs.docker.com/engine/reference/commandline/manifest_inspect/

Hopefully this helps someone. :)

Parochialism answered 18/8, 2022 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.