docker system df
查看docker使用情况
[root@localhost ~]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 3 1 182MB 182MB (99%)
Containers 1 0 0B 0B
Local Volumes 0 0 0B 0B
Build Cache 0 0 0B 0B
[root@localhost ~]#
docker rmi hello-world
通过镜像名称从docker仓库中删除镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 27941809078c 4 weeks ago 77.8MB
hello-world latest feb5d9fea6a5 9 months ago 13.3kB
redis 6.0.8 16ecd2772934 20 months ago 104MB
[root@localhost ~]# docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container 11a256a8709f is using its referenced image feb5d9fea6a5
[root@localhost ~]# docker rmi -f feb5d9fea6a5
Untagged: hello-world:latest
Untagged: hello-world@sha256:13e367d31ae85359f42d637adf6da428f76d75dc9afeb3c21faea0d976f5c651
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
[root@localhost ~]#
报错了,但是可以通过-f 参数强制删除
docker rmi feb5d9fea6a5
通过镜像ID从docker仓库中删除镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 27941809078c 4 weeks ago 77.8MB
hello-world latest feb5d9fea6a5 9 months ago 13.3kB
redis 6.0.8 16ecd2772934 20 months ago 104MB
[root@localhost ~]# docker rmi feb5d9fea6a5
Error response from daemon: conflict: unable to delete feb5d9fea6a5 (must be forced) - image is being used by stopped container 11a256a8709f
[root@localhost ~]#
[root@localhost ~]# docker rmi -f feb5d9fea6a5
Untagged: hello-world:latest
Untagged: hello-world@sha256:13e367d31ae85359f42d637adf6da428f76d75dc9afeb3c21faea0d976f5c651
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
[root@localhost ~]#
docker rmi aaa bbb ccc
同时删除多个镜像
删除所有的docker镜像
docker rmi -f $(docker images -qa) 或者
docker rmi -f `docker images -qa`
其实就是两个命令的组合使用,先通过docker images -qa查出来所有的镜像ID,然后再删除