Skip to content

Instantly share code, notes, and snippets.

@Jekis
Forked from mlebkowski/cleanup-docker.sh
Last active August 23, 2022 02:15
Show Gist options
  • Save Jekis/4726cd664e8fa3a8758ac39b1f704c4f to your computer and use it in GitHub Desktop.
Save Jekis/4726cd664e8fa3a8758ac39b1f704c4f to your computer and use it in GitHub Desktop.
Cleanup docker disk space
#!/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 -f dangling=true | awk '{ print $2 }' | xargs docker volume rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment