Skip to content

Instantly share code, notes, and snippets.

@rsignell-usgs
Created March 2, 2017 16:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rsignell-usgs/d2e2bafef7c328cecb5afd5af2f7d2b8 to your computer and use it in GitHub Desktop.
Save rsignell-usgs/d2e2bafef7c328cecb5afd5af2f7d2b8 to your computer and use it in GitHub Desktop.
Delete useless Docker image containers and volumes
#!/bin/bash
# from Kitware Jan 2017 newsletter
# remove dead and exited containers
docker ps --filter status=dead --filter status=exited -aq \
| xargs -r docker rm -v
# remove unused images
docker images --no-trunc | grep '<none>' \
| awk '{print $3 }' \
| xargs -r docker rmi
# remove unused volumes
docker volume ls -qf dangling=true \
| xargs -r docker volume rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment