清除坏的\:\镜像
docker rmi $(docker images -f "dangling=true" -q)
docker image prune移除没有标签并且没有被容器引用的镜像,这种镜像称为 dangling(摇晃的) 镜像。
docker image prune
示例2:移除所有没有容器使用的镜像 -a
docker image prune -a
跳过警告提示:--force或-f
docker image prune -f
删除停止创建超过24小时的镜像。
docker image prune -a --filter "until=24h"
存储卷可以被一个或者多个容器使用,也会占据磁盘空间。为保持数据,存储卷永远都不会自动被删除。
docker volume prune
docker网络并不会占据磁盘空间,但是会创建iptables规则,桥网络设备和路由表。因此,但如何不再使用这些资源时,应该对其进行清理。
docker network prune
通过docker system prune命令能够快速的删除所有的未被使用的对象,包括镜像、容器、网络和存储卷。在docker 17.06.0之前,存储卷会同时被清理。在docker 17.06.1之后,需要通过设置–volumes字段,才会同时清理存储卷。
docker system prune
如果所使用的docker 17.06.1之后的版本,则需要在命令后添加–volumes字段来清理存储卷的内容。
docker system prune --volumes