Skip to content

Instantly share code, notes, and snippets.

@mgurov
Last active February 7, 2016 07:07
Show Gist options
  • Save mgurov/ca83f78e73f4ac0a2c7d to your computer and use it in GitHub Desktop.
Save mgurov/ca83f78e73f4ac0a2c7d to your computer and use it in GitHub Desktop.
Docker remove all cotainers except for with given name (mvn_repository) and untagged images
#!/bin/bash -eux
E=$(docker ps -aq --filter "name=mvn_repository")
docker ps -aq | grep -v ${E:-lookup_failed} | xargs docker rm -f
docker images | sed -E 's/ +/ /g' | grep "^<none> <none>" | cut -d ' ' -f 3 | xargs docker rmi -f
@mgurov
Copy link
Author

mgurov commented Jul 21, 2015

might need -f at the end

@mgurov
Copy link
Author

mgurov commented Feb 7, 2016

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