Skip to content

Instantly share code, notes, and snippets.

@drstearns
Last active March 31, 2017 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drstearns/fdc2ca29ee82c1810d85387e17dcc1c6 to your computer and use it in GitHub Desktop.
Save drstearns/fdc2ca29ee82c1810d85387e17dcc1c6 to your computer and use it in GitHub Desktop.
Script to clean up exited docker containers and dangling docker images
#!/bin/bash
cids=$(docker ps -f "status=exited" -aq)
if [ "$cids" ]; then
docker rm $cids
fi
iids=$(docker images -q --filter "dangling=true")
if [ "$iids" ]; then
docker rmi $iids
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment