Skip to content

Instantly share code, notes, and snippets.

@Phitherek
Created March 21, 2018 12:59
Show Gist options
  • Save Phitherek/9a72afed9fd8aab81c251934d6a8743c to your computer and use it in GitHub Desktop.
Save Phitherek/9a72afed9fd8aab81c251934d6a8743c to your computer and use it in GitHub Desktop.
An updated version of the Docker cleanup script, originally from https://lebkowski.name/docker-volumes/
#!/bin/bash
# remove 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