Created
November 24, 2017 14:35
-
-
Save franciscoruiz/ab2f666d6a34fadd9b34d082fa5183e0 to your computer and use it in GitHub Desktop.
Utility to remove all containers in certain status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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