remove all stopped docker containers
docker ps -aq \
| xargs -r docker inspect \
--format='{{if not .State.Running}}{{or .ID .Id}}{{end}}' \
| xargs -r docker rm
- works fine if there is nothing to delete
- uses actual docker semantics, not grep / awk
-
set -o pipefail
for even less opportunity for bash to ruin everything
Written by Tim Cuthbertson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Cleanup
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#