Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active October 30, 2022 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilangvperdana/6deb457f996ad9e8b4e17f88080dca0e to your computer and use it in GitHub Desktop.
Save gilangvperdana/6deb457f996ad9e8b4e17f88080dca0e to your computer and use it in GitHub Desktop.

Automaticly delete image dangling on Docker Image

  • Create script
nano dockerimageprune.sh
#!/bin/bash

docker image prune -a -f
chmod +x dockerimageprune.sh
  • Create crontab
crontab -e
## This is example if we want to execute scipt every minute. For design crontab you can goes to this [web](https://crontab-generator.org/).
* * * * * bash /root/dockerimageprune.sh >/dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment