Optimizing Kubernetes Registry: How to Remove Unused Images

In this blog post, we will take a look at a common problem that many Kubernetes users face: dealing with outdated or unused images in their container registry. Over time, it’s natural for a registry to accumulate a large number of images, many of which may no longer be needed. This can cause a number of problems, including increased storage costs and reduced performance. Fortunately, there are a few simple steps you can take to clean up your registry and get rid of unwanted images.

The first step is to identify the images that are taking up the most space in your registry. This can be done using the docker images command, which will list all the images in your registry along with their size. For example, the following command will list the top 10 images in your registry by size:

docker images --format "{{.Repository}}:{{.Tag}} {{.Size}}" | sort -rnk 2 | head -10

Once you have identified the largest images in your registry, the next step is to determine which of these images are still in use. You can do this using the kubectl command, which allows you to query your Kubernetes cluster for information about the containers it is running. For example, the following command will list all the containers in your cluster that are using an image from the my-registry registry:

kubectl get pods -o=jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}{end}' | grep my-registry

Using the output from these commands, you can then determine which images are no longer in use and can be safely deleted from your registry. To delete an image, you can use the docker rmi command, followed by the image name and tag. For example, the following command will delete the my-image:latest image from your registry:

docker rmi my-registry/my-image:latest

By following these steps, you can quickly and easily clean up your Kubernetes container registry and get rid of outdated or unused images. This will help you to reduce your storage costs and improve the performance of your cluster.

In conclusion, dealing with outdated or unused images in your Kubernetes container registry is a common problem, but it is easy to solve using the docker and kubectl commands. By following the steps outlined in this blog post, you can quickly and easily clean up your registry and get rid of unwanted images. This will help you to keep your registry organized and running smoothly.

At Pacewisdom, we have a team of skilled DevOps professionals who are experts in Kubernetes and other cloud-native technologies. We can help you to design and implement a Kubernetes solution that is tailored to your unique requirements and infrastructure. Our team will work closely with you to understand your business goals and objectives and will provide expert guidance and support throughout the process.

Whether you are just getting started with Kubernetes or are looking to upgrade your existing deployment, our team can provide the knowledge and expertise you need to succeed. We offer a range of services, including Kubernetes consulting, deployment, and support, to help you get the most out of your investment in this powerful platform.

Contact us today to learn more about how our team can help you implement a Kubernetes solution for your infrastructure. 


HTTP/3 is the latest version of the HTTP protocol, and it offers significant improvements over previous versions, including improved performance and increased security. In
Redis is a popular in-memory data store that is widely used to improve the performance of software applications. In this comprehensive guide, we delve
Here is a complete guide for streamlining engineering troubleshooting. Troubleshooting is time-consuming and tiring. From API timeouts to network issues and misconfigurations, engineers must

Digital Services for tomorrow’s enterprise

Scroll to Top