Created
March 22, 2018 11:43
-
-
Save konjoot/7122d3ce3f37bd688798e3bb379665ca to your computer and use it in GitHub Desktop.
Docker full reset. Removes all docker containers, images, networks and volumes
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
#!/usr/bin/env bash | |
RUNNING_CONTAINERS=`docker ps -aq` | |
if [[ $RUNNING_CONTAINERS ]]; then | |
docker stop $RUNNING_CONTAINERS | |
docker rm -f $RUNNING_CONTAINERS | |
fi | |
docker network prune -f | |
DOCKER_TEMP_IMAGES=`docker images --filter dangling=true -qa` | |
if [[ $DOCKER_TEMP_IMAGES ]]; then | |
docker rmi -f DOCKER_TEMP_IMAGES | |
fi | |
DOCKER_TEMP_VOLUMES=`docker volume ls --filter dangling=true -q` | |
if [[ $DOCKER_TEMP_VOLUMES ]]; then | |
docker volume rm -f $DOCKER_TEMP_VOLUMES | |
fi | |
DOCKER_ALL_IMAGES=`docker images -qa` | |
if [[ $DOCKER_ALL_IMAGES ]]; then | |
docker rmi -f $DOCKER_ALL_IMAGES | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment