Created
April 6, 2020 00:03
-
-
Save appler1009/15fdd28d21e856560528f3d27b290960 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script that frees up docker-related diskspace, by removing old images and dangling resources. | |
| echo Removing all but the latest app image... | |
| docker images --format '{{.Repository}}:{{.Tag}}' | grep 'product-sigtran' | sort -r | tail -n +2 | xargs docker rmi | |
| echo Removing exited containers... | |
| docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v | |
| echo Removing unused images... | |
| docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs docker rmi | |
| echo Remove unused volumes... | |
| docker volume ls -qf dangling=true | xargs docker volume rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment