Last active
June 16, 2017 11:33
-
-
Save rsercano/48a4bbcaaf253a0c1c4cec6c973df760 to your computer and use it in GitHub Desktop.
Docker remove all containers and images
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 | |
# Stop all containers | |
docker stop $(docker ps -a -q) | |
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images | |
docker rmi $(docker images -q) | |
# Delete all exited containers | |
sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm | |
# Delete all unused images | |
docker images -q |xargs docker rmi | |
# Clean up | |
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' \ | |
| xargs -r docker rmi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment