Skip to content

Instantly share code, notes, and snippets.

@carlosrabelo
Created July 25, 2019 21:48
Show Gist options
  • Save carlosrabelo/036f9985990ef5512e49b04476e49ea5 to your computer and use it in GitHub Desktop.
Save carlosrabelo/036f9985990ef5512e49b04476e49ea5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# remove exited containers:
docker ps -aq --filter status=dead --filter status=exited | xargs -r docker rm -v
# remove unused images:
docker images -qf dangling=true --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