Skip to content

Instantly share code, notes, and snippets.

@jolbax
Last active August 24, 2017 08:05
Show Gist options
  • Save jolbax/b764ce4354c1dca1959012baae32e783 to your computer and use it in GitHub Desktop.
Save jolbax/b764ce4354c1dca1959012baae32e783 to your computer and use it in GitHub Desktop.
Shell to delete orphaned docker volumes in /var/lib/docker/volumes #docker
To delete orphaned volumes in Docker 1.9 and up you can also use the built-in docker volume commands instead of this docker-cleanup-volumes script. The built-in command also deletes any directory in /var/lib/docker/volumes that is not a volume so make sure you didn't put anything in there you want to save:
List:
$ docker volume ls -qf dangling=true
Cleanup:
$ docker volume rm $(docker volume ls -qf dangling=true)
Or, handling a no-op better but Linux specific:
$ 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