Run the below command to identify dangling images in the docker registry
- docker images -aq -f 'dangling=true'
To identify the dangling images in a kubernetes cluster, follow the below steps:
1. Create a script dangling.sh with the below content
- sudo -i /var/vcap/packages/docker/bin/docker images -aq -f 'dangling=true'|wc -l
2. Copy the script to all worker nodes
- bosh -d service-instance_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx scp dangling.sh worker:/var/tmp
3. Run dangling.sh script to see the number of dangling images in each kubernetes worker nodes
- bosh -d service-instance_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ssh worker -c 'sudo sh /var/tmp/dangling.sh'
4. Run the below command to remove the dangling images
- docker images -aq -f 'dangling=true' | xargs docker rmi