镜像查看
查看镜像
[root@hmm-docker ~]# docker images
REPOSITORY#镜像仓库 TAG #标签 IMAGE ID#镜像id CREATED #创建时间 SIZE#大小
my-hello latest 6d0c09473a66 20 hours ago 861kB
ubuntu latest 3db8720ecbf5 3 weeks ago 77.9MB
httpd latest 2776f4da9d55 7 weeks ago 167MB
ubuntu 18.04 f9a80a55f492 9 months ago 63.2MB
centos latest 5d0da3dc9764 2 years ago 231MB
ubuntu 14.04 13b66b487594 2 years ago 197MB
查看镜像的摘要值
[root@hqs-docker ~]# docker images ubuntu --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
ubuntu latest sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da 3db8720ecbf5 3 weeks ago 77.9MB
ubuntu 18.04 sha256:152dc042452c496007f07ca9127571cb9c29697f42acbfad72324b2bb2e43c98 f9a80a55f492 9 months ago 63.2MB
ubuntu 14.04 <none> 13b66b487594 2 years ago 197MB
查看镜像完整id
[root@hqs-docker ~]# docker images ubuntu --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest sha256:3db8720ecbf5f5927d409cc61f9b4f7ffe23283917caaa992f847c4d83338cc1 3 weeks ago 77.9MB
ubuntu 18.04 sha256:f9a80a55f492e823bf5d51f1bd5f87ea3eed1cb31788686aa99a2fb61a27af6a 9 months ago 63.2MB
ubuntu 14.04 sha256:13b66b487594a1f2b75396013bc05d29d9f527852d96c5577cc4f187559875d0 2 years ago 197MB
自定义镜像模板输出
- 输出json模式
[root@hqs-docker ~]# docker images centos --format json
{"Containers":"N/A","CreatedAt":"2021-09-16 02:20:05 +0800 CST","CreatedSince":"2 years ago","Digest":"\u003cnone\u003e","ID":"5d0da3dc9764","Repository":"centos","SharedSize":"N/A","Size":"231MB","Tag":"latest","UniqueSize":"N/A","VirtualSize":"231.3MB"}
- 自定义输出模板
[root@hqs-docker ~]# docker images centos --format "{{.Repository}}---{{.Tag}}"
centos---latest
[root@hqs-docker ~]# docker images --format "{{.Repository}}--{{.Tag}}--{{.Size}}"
my-hello--latest--861kB
ubuntu--latest--77.9MB
httpd--latest--167MB
ubuntu--18.04--63.2MB
centos--latest--231MB
ubuntu--14.04--197MB
[root@hqs-docker ~]# docker images --format "{{.Repository}}:{{.Tag}}:{{.Size}}"
my-hello:latest:861kB
ubuntu:latest:77.9MB
httpd:latest:167MB
ubuntu:18.04:63.2MB
centos:latest:231MB
ubuntu:14.04:197MB****
只显示镜像id,方便批量操作
[root@hqs-docker ~]# docker images -q
6d0c09473a66
3db8720ecbf5
2776f4da9d55
f9a80a55f492
5d0da3dc9764
13b66b487594
镜像条件筛选
- dangling:标识为空的镜像,值有true和false两种
[root@hmm-docker ~]# docker image ls --filter dangling=true
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@hmm-docker ~]# docker image ls --filter dangling=false
REPOSITORY TAG IMAGE ID CREATED SIZE
my-hello latest 6d0c09473a66 20 hours ago 861kB
ubuntu latest 3db8720ecbf5 3 weeks ago 77.9MB
httpd latest 2776f4da9d55 7 weeks ago 167MB
ubuntu 18.04 f9a80a55f492 9 months ago 63.2MB
centos latest 5d0da3dc9764 2 years ago 231MB
ubuntu 14.04 13b66b487594 2 years ago 197MB
- before:根据时间过滤,某个镜像构建之前的镜像
[root@hmm-docker ~]# docker image ls --filter before=6d0c09473a66
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 3db8720ecbf5 3 weeks ago 77.9MB
httpd latest 2776f4da9d55 7 weeks ago 167MB
ubuntu 18.04 f9a80a55f492 9 months ago 63.2MB
centos latest 5d0da3dc9764 2 years ago 231MB
ubuntu 14.04 13b66b487594 2 years ago 197MB
[root@hmm-docker ~]# docker image ls --filter before=ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest 2776f4da9d55 7 weeks ago 167MB
ubuntu 18.04 f9a80a55f492 9 months ago 63.2MB
centos latest 5d0da3dc9764 2 years ago 231MB
ubuntu 14.04 13b66b487594 2 years ago 197MB
[root@hmm-docker ~]# docker image ls --filter before=ubuntu:18.04
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 2 years ago 231MB
ubuntu 14.04 13b66b487594 2 years ago 197MB
- since:根据时间过滤,某个镜像构建之后的镜像
[root@hmm-docker ~]# docker image ls --filter since=ubuntu:18.04
REPOSITORY TAG IMAGE ID CREATED SIZE
my-hello latest 6d0c09473a66 20 hours ago 861kB
ubuntu latest 3db8720ecbf5 3 weeks ago 77.9MB
httpd latest 2776f4da9d55 7 weeks ago 167MB
- label:根据标签过滤
[root@hmm-docker docker-hello]# docker images --filter label=name
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-label2 latest c0dd54a49365 20 hours ago 861kB
hello-label latest 7bb17936061a 20 hours ago 861kB
hello-label3 latest fef21c202867 20 hours ago 861kB
批量删除镜像
- 通过shell命令替换dockeriamges命令可以解决镜像的批量操作
docker images -f label=name -q
docker image rm $(docker images -f label=name -q)
- 如果要删除本地所有的镜像通常会如下操作
docker rmi $(docker images -q)
标签:ago,MB,--,----,ubuntu,镜像,docker,latest
From: https://www.cnblogs.com/humlogs/p/18056762