Skip to content

Instantly share code, notes, and snippets.

@nickistre
Last active July 24, 2023 22:45
Show Gist options
  • Save nickistre/5ed2ee4826f55c2ecdca20561aef0c77 to your computer and use it in GitHub Desktop.
Save nickistre/5ed2ee4826f55c2ecdca20561aef0c77 to your computer and use it in GitHub Desktop.
Reset Docker environment
#!/usr/bin/env bash
# All in one line
docker stop $(docker ps -q) ; docker rm $(docker ps -aq) ; docker rmi -f $(docker images -q) ; docker volume prune -f ; docker network prune -f ; docker system prune -a --volumes -f
#!/usr/bin/env bash
# To quickly reset a docker environment
# Stop currently running docker containers
docker stop $(docker ps -q)
# Remove all docker containers
docker rm $(docker ps -aq)
# Force remove all docker images
docker rmi -f $(docker images -q)
# Remove unused volumes
docker volume prune -f
# Remove unused networks
docker network prune -f
# Final run to remove all unused images and volumes
docker system prune -a --volumes -f
#!/usr/bin/env bash
# All in one line
docker stop $(docker ps -q) ; docker rm $(docker ps -aq) ; docker volume prune -f ; docker network prune -f
#!/usr/bin/env bash
# To quickly reset a docker environment
# Stop currently running docker containers
docker stop $(docker ps -q)
# Remove all docker containers
docker rm $(docker ps -aq)
# Remove unused volumes
docker volume prune -f
# Remove unused networks
docker network prune -f
#!/usr/bin/env bash
# To quickly stop all running containers
# Stop currently running docker containers
docker stop $(docker ps -q)
@nickistre
Copy link
Author

@NorseGaud Thanks! Added it to my docker-reset-full scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment