Reputation: 86057
Docker docs give:
docker image ls [OPTIONS] [REPOSITORY[:TAG]]
but this assumes you'll specify a repo.
How do you list local images just by tag?
Upvotes: 5
Views: 17829
Reputation: 25122
Nice question! I was playing with docker image ls
and have found that you do not have to specify repository. The following actually work:
# displays images with tag: latest
docker image ls *:latest
# displays all images but not those with: <none>
docker image ls *:*
edit:
docker image ls *:latest
has some inconsistencies. I noticed that some images are not displayed whereas docker image ls | grep latest
shows them. I'll get back if I find out why...
Update by Santhosh V:
It looks like a special character needs to be specified in the filter like docker image ls *\*:*
for considering a \ in the image name
Upvotes: 5
Reputation: 1675
The following works on Docker version 20.10.6, build 370c289
docker images --filter=reference='*:sometag'
The official documentation can help you with more such filters.
Upvotes: 1
Reputation: 32156
You will use the Docker API, see the doc
https://docs.docker.com/registry/spec/api/#listing-image-tags
see also
https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721
If the Docker API is on
http://myregistry.com
on the port 2375, then you will do something like
curl http://myregistry.com:2375/images/json
you will find in /images/json the same info as
docker images
will show
Upvotes: 0
Reputation: 2125
You can't just with the docker CLI on it's own. The CLI only supports listing all images (including or excluding intermediate layers), images matching a repo, or images matching a repo:tag.
In a shell then you can pipe to grep as has been mentioned in comments, otherwise you will have to parse the output of whichever method you use to list images.
Upvotes: 2