Filter docker images by repository name

Docker

Docker Problem Overview


Using the command docker images, you can list all images on your host:

REPOSITORY                   TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
scdockerdemo_php             latest              155d80ea7642        4 minutes ago       265.3 MB
scdockerdemo_node            latest              6189bc65c3fe        8 minutes ago       861.4 MB
php                          5.6-apache          fc50bce69ea0        3 days ago          481.3 MB
node                         4.1                 fc81e574af43        3 days ago          641.1 MB

With docker images -f "tag=latest", you can filter for images with a certain tag.

How can I filter for a repository name? E.g. docker images -f "repository=scdockerdemo_*"

This command always return Invalid filter 'repository'

https://docs.docker.com/reference/commandline/images/

Docker Solutions


Solution 1 - Docker

If you want to filter by repository name(eg: testImage), just use the following:

docker images testImage

When you have multiple images with same repository name but diffetent tags, you can specify tags on the repository name by using a ':' ( For example, testImage:<whatever tag>)

Source: Docker images

Solution 2 - Docker

According to the documentation at https://docs.docker.com/engine/reference/commandline/images/ you can match by wildcard by enclosing in double quotes:

docker images "scdockerdemo_*"

** special chars ** when you have special characters like '/' in the repository name, you should escape it to filter by repository name.

ex)

> docker images "zirho6\/*"
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
zirho6/aaaa              latest              946bf5cc28fc        2 days ago          997MB
zirho6/bbbb              latest              741a6e368d07        10 days ago         866MB
zirho6/ccc               latest              173b36570522        12 days ago         853MB
zirho6/dddd              latest              e08e5c202e9b        13 days ago         853MB

Solution 3 - Docker

You can filter images by reference (combination of name and tag):

docker image ls --filter 'reference=scdockerdemo_*'

Solution 4 - Docker

According to this answer to a similar question, the filter option currently only supports "dangling=true".

If you're using Bash, the easiest thing to do is probably:

$ docker images | grep scdockerdemo

Or, you can try using awk to match on a string in the first column:

$ docker images | awk '$1 ~ /scdockerdemo/ { print }'

Solution 5 - Docker

Provide another option for reference

> docker images | ruby -ne ' puts $_ if $_ =~ /harbor/ '

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkuffelView Question on Stackoverflow
Solution 1 - DockerVikasView Answer on Stackoverflow
Solution 2 - DockerD. WitherspoonView Answer on Stackoverflow
Solution 3 - DockermdhView Answer on Stackoverflow
Solution 4 - DockerLeoView Answer on Stackoverflow
Solution 5 - DockerjiahutView Answer on Stackoverflow