├── README.md └── Unraid_check_docker_script.sh /README.md: -------------------------------------------------------------------------------- 1 | # Unraid_check_docker_script 2 | Script to troubleshoot what is filling up Unraid docker image 3 | 4 | This script is to help troubleshoot why an Unraid docker image is getting too big. 5 | 6 | The script when run will 7 | 1. Show how much total space your Docker images, containers and volumes are taking up. 8 | 2. Shows how mcuh space each container is taking up (both writable layer and combined read/writable layer size) 9 | 3. Will list container size in order from highest to lowest size 10 | 4. Shows each docker volume, its size and which container it is connected to 11 | 5. Can be set to remove both orphaned images and unconnected docker volumes when run. 12 | 13 | 14 | Usage 15 | 16 | With user script plugin installed copy and paste script to your Unraid server. 17 | By default script will not remove orpaned images or unconected docker volumes. Set variables to "yes" to have script remove them. 18 | Run script and use it to find out which container or docker image is taking up too much space. 19 | Once you find out what is the culprit check all of your docker mappings for that container. Also check inside the container (a download container like nzbget for example) 20 | that the internal paths are set to a mapped location. 21 | -------------------------------------------------------------------------------- /Unraid_check_docker_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | remove_orphaned_images="no" # select "yes" or "no" to remove any orphaned images 4 | remove_unconnected_volumes="no" # select "yes" or "no" to remove any unconnected volumes 5 | 6 | # Do not make changes below this line # 7 | 8 | echo "##################################################################################" 9 | echo "Cleanup before starting (if requested in script)" 10 | echo "##################################################################################" 11 | echo 12 | if [ "$remove_orphaned_images" == "yes" ] ; then 13 | echo "Removing orphaned images..." 14 | echo 15 | docker image prune -af 16 | else 17 | echo "Not removing orphaned images (this can be set in script if you want to)" 18 | fi 19 | echo 20 | echo "---------------------------------------------------------------------------------" 21 | echo 22 | if [ "$remove_unconnected_volumes" == "yes" ] ; then 23 | echo "Removing unconnected docker volumes" 24 | echo 25 | docker volume prune -f 26 | else 27 | echo "Not removing unconnected docker volumes (this can be set in script if you want to)" 28 | fi 29 | echo 30 | echo "##################################################################################" 31 | echo "List of Image, Container and docker volume size." 32 | echo "##################################################################################" 33 | echo 34 | #docker system df 35 | docker system df --format 'There are \t {{.TotalCount}} \t {{.Type}} \t taking up ......{{.Size}}' 36 | echo 37 | echo "##################################################################################" 38 | echo "List of containers showing size and virtual size" 39 | echo "##################################################################################" 40 | echo 41 | echo "First size is the writable layers of the container (Virtual size is writable and read only layers)" 42 | echo 43 | docker container ls -a --format '{{.Size}} \t Is being taken up by ......... {{.Image}}' 44 | echo 45 | echo "##################################################################################" 46 | echo "List of containers in size order" 47 | echo "##################################################################################" 48 | echo 49 | docker image ls --format "{{.Repository}} {{.Size}}" | \ 50 | awk '{if ($2~/GB/) print substr($2, 1, length($2)-2) *1000 "MB - " $1 ; else print $2 " - " $1 }' | \ 51 | sed '/^0/d' | \ 52 | sort -nr 53 | echo 54 | echo "##################################################################################" 55 | echo "List of docker volumes, the container which they are connected to their size" 56 | echo "##################################################################################" 57 | echo 58 | volumes=$(docker volume ls --format '{{.Name}}') 59 | for volume in $volumes 60 | do 61 | name=`(docker ps -a --filter volume="$volume" --format '{{.Names}}' | sed 's/^/ /')` 62 | size=`(du -sh $(docker volume inspect --format '{{ .Mountpoint }}' $volume) | cut -f -1)` 63 | echo "ID" "$volume" 64 | echo "This volume connected to" $name "has a size of" $size 65 | echo "" 66 | done 67 | echo 68 | echo "##################################################################################" 69 | echo 70 | echo "Done. Scroll up to view results" 71 | exit --------------------------------------------------------------------------------