Created
July 4, 2017 13:03
-
-
Save kirkins/c1f3fecbdd0a58bcc9c645172c3d3236 to your computer and use it in GitHub Desktop.
Quick commands for removing docker images and containers
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
# command to remove all containers and images, with y/N prompt | |
rmdocker() { | |
read -r -p "Are you sure you want to remove all docker data? [y/N] " response | |
case "$response" in | |
[yY][eE][sS]|[yY]) | |
docker kill $(docker ps -q) | |
docker rm $(docker ps -a -q) | |
docker rmi $(docker images -q) | |
docker volume rm $(docker volume ls -q) | |
docker network rm $(docker network ls -q) | |
;; | |
*) | |
esac | |
} | |
# command to remove all containers but not images | |
rmcontainers() { | |
docker kill $(docker ps -q) | |
docker rm $(docker ps -a -q) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment