英文:
List docker images with a given tag
问题
I want to list all images with the tag foo
, regardless of repository name.
What I've tried:
docker images --filter=reference='*:foo'
With the following images on the daemon:
x/y/z:foo
y/z:foo
z:foo
The above command will list only the z:foo
image.
I cannot find anywhere documented how the Docker CLI interprets these wildcards. I've found other answers, where people state that you generally need to look into the Go code for that (?!). For example, in order to realize that the *
wildcard will not match the /
character. As long as it is not documented, I guess it is urban legend, although I can reproduce it.
In any case, I'll restate the question:
How to list all images on docker daemon with tag name foo
, regardless of repository name.
英文:
I want to list all images with the tag foo
, regardless of repository name.
What I've tried:
docker images --filter=reference='*:foo'
With the following images on the daemon:
x/y/z:foo
y/z:foo
z:foo
.. the above command will list only the z:foo
image.
I cannot find anywhere documented how the Docker CLI interprets these wildcards. I've found other answers, where people state that you generally need to look into the Go code for that (?!). For example, in order to realize that the *
wildcard will not match the /
character. As long as it is not documented, I guess it is urban legend, although I can reproduce it.
In any case, I'll restate the question:
How to list all images on docker daemon with tag name foo
, regardless of repository name.
答案1
得分: 1
docker images | awk '$2 == "foo"'
x/y/z foo f1329e1a30c0 5周前 691MB
y/z foo 180697b5c4fb 6周前 1.39GB
z foo 2ee88e314807 6周前 1.51GB
英文:
You can always pipe output to other tools, like awk
:
docker images | awk '$2 == "foo"'
x/y/z foo f1329e1a30c0 5 weeks ago 691MB
y/z foo 180697b5c4fb 6 weeks ago 1.39GB
z foo 2ee88e314807 6 weeks ago 1.51GB
答案2
得分: 0
@Justinas已经给出了一个很好的答案,但是关于`docker images --filter=reference`通配符的详细说明是,它不匹配`/`,但如果你真的想使用它,你可以使用多个过滤器:
```terminal
docker images --filter=reference="*:foo" --filter=reference="*/*:foo" --filter=reference="*/*/*:foo"
<details>
<summary>英文:</summary>
@Justinas has already given a good answer, but to elaborate on the `docker images --filter=reference` wildcard, it does not match `/`, but if you really want to use it you can use multiple filters:
```terminal
docker images --filter=reference="*:foo" --filter=reference="*/*:foo" --filter=reference="*/*/*:foo"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论