脚本del_docker_images.sh
:
#!/bin/bash
imageIds=$(docker images | awk '{print $3}' | sed -n '2,$p' | sort -k2n | uniq)
for imageId in $imageIds
do
docker rmi $imageId
if [ $? -ne 0 ]; then
echo "failed to remove image:["$imageId"], skipped and remove next one"
fi
done;
docker system prune -a
docker volume prune
用法:
$ bash del_docker_images.sh