Topics: Docker, Kubernetes, Red Hat / Linux, System Admin

Prune old Docker data

When using Docker, or when using Docker as a container run-time for Kubernetes, over time, some unused data may build up on the system that runs Docker, for example on worker nodes of a Kubernetes cluster. This unused data may include images that were once downloaded locally, but are no longer used, for example, when a deployment to Kubernetes was once done, but later removed. This unused data may become quite a lot of data, and file systems may over time fill up because of this.

There is a simple Docker command that will prune all the unused data, and this command is:

# docker system prune -a
If you don't want to worry about pruning any unused Docker data, then schedule a cron job on your system as user root, like this:
0 */12 * * * * docker system prune -a -f

If you found this useful, here's more on the same topic(s) in our blog:

UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.

Interested in learning more?