Skip to content

Instantly share code, notes, and snippets.

@franciscoruiz
Created November 24, 2017 14:35
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 franciscoruiz/ab2f666d6a34fadd9b34d082fa5183e0 to your computer and use it in GitHub Desktop.
Save franciscoruiz/ab2f666d6a34fadd9b34d082fa5183e0 to your computer and use it in GitHub Desktop.
Utility to remove all containers in certain status
# docker-rm-in-status (exited|created|running)
docker-rm-in-status ()
{
local status="${1:-exited}";
matching_containers=$(docker ps -aq --filter status="${status}");
if [[ -z "${matching_containers}" ]]; then
echo "No matching containers";
else
echo "Removing containers";
docker rm --volumes --force ${matching_containers};
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment