Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Last active March 15, 2026 02:27
Show Gist options
  • Select an option

  • Save mlebkowski/471d2731176fb11e81aa to your computer and use it in GitHub Desktop.

Select an option

Save mlebkowski/471d2731176fb11e81aa to your computer and use it in GitHub Desktop.
Cleanup docker disk space 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:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
docker ps -aq | xargs docker inspect | jq -r '.[] | .Mounts | .[] | .Name | select(.)'
) | xargs -r rm -fr
@alexsmredman
Copy link
Copy Markdown

alexsmredman commented Dec 16, 2020

Where is the updates Lebkowski?! Where is the updates?!!!!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment