How to identify and remove dangling registry images in docker registry
search cancel

How to identify and remove dangling registry images in docker registry

book

Article ID: 316806

calendar_today

Updated On:

Products

VMware Cloud PKS

Issue/Introduction

This article helps to identify and remove dangling registry images in docker registry

Symptoms:
Docker registry is filled with dangling images

Environment

VMware PKS 1.x

Resolution

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


Additional Information

Impact/Risks:
Dangling images are layers that have no relationship to any tagged images. They no longer serve a purpose and consume disk space.