Docker Prune: prevent running out of disk space

Running out of disk space when running docker? You can clean up all images, containers, networks, and volumes not used on your drive. Run with a -f flag to skip a confirmation prompt. Run with a -a to remove all unused images and not just the dangling ones. Check the docs.

command

We’ve seen this happen when running Jenkins and building a docker image based on an automated deploy process. Jenkins will continuosly build an image and make that latest image active but old image artifacts will still be remaining on the server. All is well until one day, the build fails because of lack of disk space. We added a cron job command of:

docker system prune -af

-f to avoid any interaction and -a to remove all images, to fix this issue and not worry about a jenkins build randomly failing 😅.

Not sure what docker is and want to get started? Check out our getting started with docker post

Instagram Post