Last active
May 25, 2024 20:19
-
-
Save JeffBelback/5687bb02f3618965ca8f to your computer and use it in GitHub Desktop.
Destroy all Docker 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 | |
containers=`docker ps -a -q` | |
if [ -n "$containers" ] ; then | |
docker stop $containers | |
fi | |
# Delete all containers | |
containers=`docker ps -a -q` | |
if [ -n "$containers" ]; then | |
docker rm -f -v $containers | |
fi | |
# Delete all images | |
images=`docker images -q -a` | |
if [ -n "$images" ]; then | |
docker rmi -f $images | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please add remove all volumes too