批量删除没用的docker镜像、container、volume脚本

T
TrumanWong
11/2/2022

脚本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
อ่านต่อ

เนื้อหาเหล่านี้อาจเป็นประโยชน์ต่อไป

คำแนะนำที่เกี่ยวข้อง ประวัติการอ่าน และบทความที่บันทึกไว้

แนะนำ

ดูล่าสุด

ยังไม่มีประวัติการอ่าน

รายการที่บันทึก

บทความที่บันทึกจะแสดงที่นี่