目录
article
Docker 镜像清理(docker image prune)
Docker 镜像清理(docker image prune)
Remove all dangling images. If -a is specified, will also remove all images not referenced by any container.
删除所有 maintainer 为 XYB 或 MrBird 的镜像。
docker image prune --filter="label=maintainer=XYB" --filter="label=maintainer=MrBird"
参数
--all、-a清除所有没有容器引用的镜像。
--filter筛选要删除的镜像。
- until (
<timestamp>) - only remove images created before given timestamp - label (
label=<key>,label=<key>=<value>,label!=<key>, orlabel!=<key>=<value>) - only remove images with (or without, in caselabel!=...is used) the specified labels.
- until (
-f、--force跳过提示信息强制执行清理操作。
清理 Jenkins 打包服务器上的镜像
由于 --filter 指定的 maintainer 无法起作用,所以修改为使用 grep 来删除旧的镜像。
示例如下:
docker images|grep t_|awk '{print $3}'|xargs docker rmi