Created
January 21, 2016 21:37
-
-
Save psbrandt/ae0643c2989a492e0e05 to your computer and use it in GitHub Desktop.
Obliterate Docker containers and images matching name.
This file contains 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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo $0: usage: dockerkill containername | |
exit 1 | |
fi | |
containername=$1 | |
# stop any running containers | |
docker ps | grep $1 | awk '{print $1}' | xargs docker stop | |
# remove the container | |
docker ps -a | grep $1 | awk '{print $1}' | xargs docker rm | |
# remove the image | |
docker images | grep $1 | awk '{print $3}' | xargs docker rmi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment