Docker基本命令-images篇
作用
列出当前环境中镜像信息(默认只显示顶层镜像信息)
格式
docker images [OPTIONS] [REPOSITORY[:TAG]]
REPOSITORY[:TAG]
根据仓库信息列出的镜像信息,有关此命令的示例用法,请参阅下面的示例部分。
- 列出最近创建的镜像信息
docker images
- 列出仓库名称为tomcat的镜像信息
docker images tomcat
- 列出仓库名称为tomcat且标签为latest的镜像信息
docker images tomcat:latest
注意:仓库信息必须是"完全匹配",当仓库名称不匹配时,返回空列表
OPTIONS
名称 | 作用 |
---|---|
–all,-a | 显示所有顶层镜像信息 |
–digests | 镜像信息中增加摘要信息 |
–filter,-f | 根据条件过滤 |
–format | 按照自定义的Go模板进行输出镜像信息 |
–no-trunc | 不截断输出 |
–quiet,-q | 只显示镜像ID |
根据选项信息列出的镜像信息,有关此命令的示例用法,请参阅下面的示例部分。
- 列出当前环境中所有镜像信息
docker images --all
- 列出镜像信息中显示摘要
docker images --digests
- 列出完整镜像ID的镜像信息
docker images --no-trunc
-
筛选符合条件的镜像信息
4.1 筛选悬空(仓库或标签为none)的镜像信息docker images --filter "dangling=true"
4.2 筛选具有version标签的镜像信息
docker images --filter "label=version"
4.3 筛选具有version标签且值为1的镜像信息
docker images --filter "label=version=1"
4.4 筛选创建时间在hello-world:latest镜像之前的镜像信息
docker images --filter "before=hello-world"
4.5 筛选创建时间在hello-world:latest镜像之后的镜像信息
docker images --filter "since=hello-world"
注意:使用before或since时tag默认为latest,标签不是latest的镜像请补全
4.6 筛选仓库名以hello开头的镜像信息docker images --filter=reference='hello*'
4.7 筛选仓库名以hello开头,标签名以test结尾的镜像信息
docker images --filter=reference='hello*:*test'
-
以自定义格式打印镜像信息
符 描述 D 镜像ID epository 镜像仓库名 ag 镜像标记 igest 镜像摘要 reatedSince 镜像创建以来经过的时间 reatedAt 镜像创建的时间 ize 镜像磁盘大小 5.1 使用不带标头的模板打印镜像仓库名==>镜像ID==>镜像大小格式的镜像信息
docker images --format "{{.Repository}}==>{{.ID}}==>{{.Size}}"
5.2 使用带标头的模板打印镜像仓库名==>镜像ID==>镜像大小格式的镜像信息
docker images --format "table {{.Repository}}==>{{.ID}}==>{{.Size}}"