13

I installed microk8s and I enabled registry addon I am able to push docker images to this registry and I am able to use this images in deployments.

But I'm trying to list images that was already pushed to this registry. How can I do that? Is there an API for that?

EduMelo
  • 455
  • 3
  • 15

5 Answers5

12

Use command microk8s ctr images list. To know more use --help

microk8s ctr images --help
NAME:
   ctr images - manage images

USAGE:
   ctr images command [command options] [arguments...]

COMMANDS:
     check       check that an image has all content available locally
     export      export an image
     import      import images
     list, ls    list images known to containerd
     pull        pull an image from a remote
     push        push an image to a remote
     remove, rm  remove one or more images by reference
     label       set and clear labels for an image

OPTIONS:
   --help, -h  show help
Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107
  • 2
    I get the following response when I run this command: "Cannot use two forms of the same flag: n namespace" – EduMelo May 20 '20 at 14:49
  • 2
    That returned a lot of information, but I cannot identify the images that were displayed. It returned their sha256 digest wich is not useful – EduMelo May 20 '20 at 15:39
  • 2
    I am looking for the image's name and its tags – EduMelo May 20 '20 at 21:50
  • I am getting only the cached images with this command. I know for a fact that there are other images on the registry that I cannot see here. Only after Kubernetes starts a pod with on of the images in the registry, that image appears in the list with this command. – Ouss Jun 21 '22 at 13:20
  • Please keep in mind that the Docker REGISTRY and the images hosted in CONTAINERD are distinct things. – Raúl Salinas-Monteagudo Jun 19 '23 at 11:01
12

I found that it's possible to list the registry images via HTTP GET in this address: http://<host_ip>:32000/v2/_catalog

It'll return the images in a json response

tangens
  • 39,095
  • 19
  • 120
  • 139
EduMelo
  • 455
  • 3
  • 15
6

Following REST APIs will do the job:

  1. Listing repositories:

http://host:32000/v2/_catalog?n=10

Last parameter n is the size of records to be returned. One can skip passing it but if you expect a long list then it's better to use pagination.

  1. Listing the images in the repository

http://host:32000/v2/repositoryName/tags/list?n=10

Note: Replace host and repositoryName accordingly.

For complete reference visit: https://docs.docker.com/registry/spec/api/#listing-repositories

Satish
  • 1,037
  • 1
  • 13
  • 20
4

Try this:

microk8s ctr images ls
Ardent Coder
  • 3,777
  • 9
  • 27
  • 53
JaskiratSra
  • 112
  • 2
  • 2
    That returned a lot of information, but I cannot identify the images that were displayed. It returned their sha256 digest wich is not useful – EduMelo May 20 '20 at 14:53
1
microk8s.ctr images ls

Run this to get your images. This is if you had installed microk8s as a snap. I'm using it on Ubuntu Core.

theBird
  • 31
  • 3