question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

With Docker 20.10.0 listImages filter no longer works

See original GitHub issue

With 20.10.0 docker removed the filter parameter when listing images.

https://docs.docker.com/engine/deprecated/#filter-param-for-imagesjson-endpoint

This causes

return dockerClient.listImagesCmd()
  .withImageNameFilter("mongo:4.2")
  .exec()
  .stream()
  .findFirst()
  .map(Image::getId);

to return the ID of the first image out of ALL images.

My current workaround for this is

try{
  return Optional.ofNullable(dockerClient.inspectImageCmd("mongo:4.2").exec().getId());
} catch (final NotFoundException e) {
  return Optional.empty();
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Tiannycommented, Jan 20, 2021

@bsideup Given the original issue example, how would it look like in 3 cases you have suggested, sorry?

ListImagesCmd listImagesCmd = dockerClient.listImagesCmd();
listImagesCmd.getFilters().put("reference", Arrays.asList("my/image"));
List<Image> images = listImagesCmd.exec();
3reactions
bsideupcommented, Dec 10, 2020

Yes, that’s correct (they removed the deprecated param)

There are several options:

  1. set the API version 1.40 or lower (make sure to update to docker-java 3.2.7)
  2. Use inspectImageCmd instead of list + filter
  3. getFilters().put(“reference”, Arrays.asList("my/image))
Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Engine release notes - Docker Documentation
Docker Engine release notes. This document describes the latest changes, additions, known issues, and fixes for Docker Engine.
Read more >
docker images - Docker Documentation
If you specify REPOSITORY but no TAG , the docker images command lists all images in ... If there is more than one...
Read more >
Docker Engine API v1.41 Reference
Filters to process on the container list, encoded as JSON (a map[string][]string ). For example, {"status": ["paused"]} will only return paused containers.
Read more >
Filtering images works but not when using docker image prune
docker image ls --filter "label=testuseradd" REPOSITORY TAG IMAGE ID CREATED SIZE testuseradd/simple example 74707eaff6fd 8 minutes ago ...
Read more >
docker image prune - Docker Documentation
If `-a` is specified, will also remove all images not referenced by any ... that a label does not have a specific value),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found