Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cleaning up some docker mess
#!/bin/bash
echo "Cleaning unused docker files..."
docker ps --all --quiet --filter="status=exited" | xargs --no-run-if-empty docker rm --volumes
IMAGES=`docker images | awk '/^<none>/ { print $3 }'`
if [[ $IMAGES ]]; then
echo -e "\nCleaning untagged images..."
docker rmi --force $IMAGES
fi
VOLUMES=`docker volume ls --quiet --filter="dangling=true"`
if [[ $VOLUMES ]]; then
echo -e "\nCleaning volumes..."
docker volume rm $VOLUMES
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.