2

I'm not able to filter images from client.images.list()

https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.list

The documentation says "name (str) – Only show images belonging to the repository name"

client.images.list(name="elixir")

EXPECTATION:

[<Image: 'elixir:1.10-alpine'>]

ACTUAL:

[<Image: 'postgres:latest'>, <Image: 'node:15-alpine'>, <Image: 'elixir:1.10-alpine'>, <Image: 'nginx:stable-alpine'>]

Bug?

Versions:

Docker version 20.10.0, build 7287ab3

>>> import docker
>>> docker.__version__
'4.4.0'
snakajim
  • 41
  • 1
  • 3

2 Answers2

2

I had to use:-

client.images.list(filters = { "reference" : "elixir:1.10-alpine"})

To return a list of images, Martins response appears to be missing the 's' off images

Joe-DN
  • 31
  • 6
  • 2
    Welcome to Stackoverflow. You basically copied Martin's answer and fixed a type in that. Rather than posting your "own" answer, just comment on Martin's one. – jhoepken Jun 08 '21 at 12:43
  • 2
    I could not comment on Martin's answer, it said I need 50 rep points. Creating a new answer was the only option I had, other than not commenting at all. I will take option 2 next time. – Joe-DN Jun 09 '21 at 12:01
  • 1
    You could always suggest an edit. – Ryan M Jun 16 '22 at 03:47
1

client.images.list(filters = { "reference" : "elixir:1.10-alpine"}) will give you what you want.

I used https://docs.docker.com/engine/api/v1.41/#operation/ImageList as the source of my inspiration.

Martin
  • 1,095
  • 9
  • 14