Created
January 9, 2023 13:24
-
-
Save YasienDwieb/774a0149f0a7ad4894d03a239619015c to your computer and use it in GitHub Desktop.
Delete docker containers and images by prefix of the name
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
# Stop and delete all containers matching the provided prefix | |
# Usage: $ drmall redis | |
drmall(){ | |
docker ps -a --filter "name=$1*" --format="{{ .Names }}" | xargs docker rm -f {} | |
} | |
# Stop and delete all image with repository name matching the provided prefix | |
# Usage: $ drmiall redis | |
drmiall(){ | |
docker images --filter "reference=$1*" --format="{{ .ID }}" | xargs docker rmi {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment