How to reclaim disk space by cleaning up unused Docker images
Docker accumulates unused image layers called dangling images every time a new build is triggered, and these are never automatically removed, gradually consuming server disk space. Running 'docker system df' gives a quick overview of how much space Docker is occupying before any cleanup begins. The command 'docker image prune -a' removes all images not referenced by any container, including stopped ones, and is sufficient to free several gigabytes in most cases. Age-based filters like '--filter until=720h' allow users to retain recent images while purging older ones. For fully automated maintenance, a weekly cron job can be configured to run the cleanup silently every Sunday and log the results.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in