Reclaim docker disk space on CI during build
Attempt to fix disk space issues by removing large docker images after they have been used. See gh-42776
This commit is contained in:
17
.github/scripts/reclaim-docker-diskspace.sh
vendored
Executable file
17
.github/scripts/reclaim-docker-diskspace.sh
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
echo "Reclaiming Docker Disk Space"
|
||||
echo
|
||||
|
||||
docker image ls --format "{{.Size}} {{.ID}}" | LANG=en_US sort -rh | while read line; do
|
||||
size=$( echo "$line" | cut -d' ' -f1 | sed -e 's/\.[0-9]*//' | sed -e 's/MB/000000/' | sed -e 's/MB/000000000/' )
|
||||
if [ $size -gt 200000000 ]; then
|
||||
image=$( echo "$line" | cut -d' ' -f2 )
|
||||
docker image rm -f $image
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished cleanup, leaving the following containers:"
|
||||
echo
|
||||
docker image ls --format "{{.Size}} {{.ID}} {{.Repository}}:{{.Tag}}" | LANG=en_US sort -rh
|
||||
echo
|
||||
df -h
|
||||
echo
|
||||
Reference in New Issue
Block a user