常规查看
docker images:显示所有顶层的镜像,它们的仓库, tag 和它们的大小
[root@moban ~]$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx 1.14 5f2d4477b7ea 5 days ago 109 MB
docker.io/nginx 1.15 e81eb098537d 5 days ago 109 MB
docker.io/nginx latest e81eb098537d 5 days ago 109 MB
idocker.io/eryajf/node 10.5 5698549796a7 3 weeks ago 618 MB
idocker.io/eryajf/jdk 1.8 36a4fcd3d962 4 weeks ago 896 MB
idocker.io/eryajf/jenkins 2.138 2dbf82c07ebe 4 weeks ago 990 MB
docker.io/busybox latest 59788edf1f3e 7 weeks ago 1.15 MB
docker.io/java latest d23bdf5b1b1b 22 months ago 643 MB
docker images docker.io/nginx:通过参数来限制列出匹配参数的镜像
[root@moban ~]$docker images docker.io/nginx
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx 1.14 5f2d4477b7ea 5 days ago 109 MB
docker.io/nginx 1.15 e81eb098537d 5 days ago 109 MB
docker.io/nginx latest e81eb098537d 5 days ago 109 MB
docker images –no-trunc:列出完整的镜像 ID
[root@moban ~]$docker images --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx 1.14 sha256:5f2d4477b7ea238f6ffb483962f4d124876277879a8aa948ae554d4268a41b04 5 days ago 109 MB
docker.io/nginx 1.15 sha256:e81eb098537d6c4a75438eacc6a2ed94af74ca168076f719f3a0558bd24d646a 5 days ago 109 MB
docker.io/nginx latest sha256:e81eb098537d6c4a75438eacc6a2ed94af74ca168076f719f3a0558bd24d646a 5 days ago 109 MB
idocker.io/eryajf/node 10.5 sha256:5698549796a78ed6e8827bbe0a9a403bac00bb3c89df4cde6db3740e9481b8df 3 weeks ago 618 MB
idocker.io/eryajf/jdk 1.8 sha256:36a4fcd3d9623088f91fd860486c038b9159cb542bad43fe2910e8023db4b5f9 4 weeks ago 896 MB
idocker.io/eryajf/jenkins 2.138 sha256:2dbf82c07ebe570efdee9ef5da3cb08f297a9f792200367d7f01299255621f28 4 weeks ago 990 MB
docker.io/busybox latest sha256:59788edf1f3e78cd0ebe6ce1446e9d10788225db3dedcfd1a59f764bad2b2690 7 weeks ago 1.15 MB
docker.io/java latest sha256:d23bdf5b1b1b1afce5f1d0fd33e7ed8afbc084b594b9ccf742a5b27080
高端查看
过滤标志--filter
,格式为key=value
。如果超过一个过滤,那么就传递多个标志 如–filter “foo=bar” –filter “bif=baz”
目前支持的过滤有:
-
dangling [布尔值 true 或 false]
-
label (label = 或 label==)
-
before ([:], or ) – 过滤出指定镜像之前的镜像
-
since ([:], or ) – 过滤出指定镜像之后的镜像
示例:
docker images –filter “dangling=true”:列出无 tag
镜像
[root@master core]$docker images --filter "dangling=true"
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> db4183094a81 About an hour ago 979MB
docker images –filter “before=docker.io/nginx:1.14″:列出 docker.io/nginx:1.14 之前的镜像
[root@moban ~]$docker images --filter "before=docker.io/nginx:1.14"
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx 1.15 e81eb098537d 5 days ago 109 MB
docker.io/nginx latest e81eb098537d 5 days ago 109 MB
idocker.io/eryajf/node 10.5 5698549796a7 3 weeks ago 618 MB
idocker.io/eryajf/jdk 1.8 36a4fcd3d962 4 weeks ago 896 MB
idocker.io/eryajf/jenkins 2.138 2dbf82c07ebe 4 weeks ago 990 MB
docker.io/busybox latest 59788edf1f3e 7 weeks ago 1.15 MB
docker.io/java latest d23bdf5b1b1b 22 months ago 643 MB
docker images –filter “since=docker.io/busybox”:列出对应镜像之后(指生成时间)的镜像
[root@moban ~]$docker images --filter "since=docker.io/busybox"
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx 1.14 5f2d4477b7ea 5 days ago 109 MB
docker.io/nginx 1.15 e81eb098537d 5 days ago 109 MB
docker.io/nginx latest e81eb098537d 5 days ago 109 MB
idocker.io/eryajf/node 10.5 5698549796a7 3 weeks ago 618 MB
idocker.io/eryajf/jdk 1.8 36a4fcd3d962 4 weeks ago 896 MB
idocker.io/eryajf/jenkins 2.138 2dbf82c07ebe 4 weeks ago 990 MB
花式删除
以上所有操作,都可以基于查询,进行批量删除的操作,删除的方式有二:
docker rmi $(docker images –filter “since=docker.io/busybox”)
另一花查
--format
选项使用 Go 模板打印出指定格式的列表
Go 模板的有效占位符如下所示:
-
.ID – 镜像 ID
-
.Repository – 镜像存储库名称
-
.Tag – 镜像 tag
-
.Digest – 镜像 digest
-
.CreatedSince – 从镜像创建到现在过去的时间
-
.CreatedAt – 镜像创建的时间
-
.Size – 镜像硬盘占用大小
当使用–format
选项时,images
命令输出模板声明的完全相同的数据,或者使用 table
指令,将包括列标题。
如下显示无列标题的数据:
[root@moban ~]$docker images --format "{{.ID}}: {{.Repository}}"
5f2d4477b7ea: docker.io/nginx
e81eb098537d: docker.io/nginx
e81eb098537d: docker.io/nginx
5698549796a7: idocker.io/eryajf/node
36a4fcd3d962: idocker.io/eryajf/jdk
2dbf82c07ebe: idocker.io/eryajf/jenkins
59788edf1f3e: docker.io/busybox
d23bdf5b1b1b: docker.io/java
显示带列标题的数据:
[root@moban ~]$docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID REPOSITORY TAG
5f2d4477b7ea docker.io/nginx 1.14
e81eb098537d docker.io/nginx 1.15
e81eb098537d docker.io/nginx latest
5698549796a7 idocker.io/eryajf/node 10.5
36a4fcd3d962 idocker.io/eryajf/jdk 1.8
2dbf82c07ebe idocker.io/eryajf/jenkins 2.138
59788edf1f3e docker.io/busybox latest
d23bdf5b1b1b docker.io/java latest
网友评论