Last active
July 4, 2019 19:41
-
-
Save jourdanrodrigues/72ec8dec135291c2ec0fa0f89757b8c3 to your computer and use it in GitHub Desktop.
Clear Docker containers, volumes, networks and images, in that specific order.
This file contains hidden or 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 | |
| function clear_docker() { | |
| docker rm --force $(docker ps -aq) # containers | |
| docker volume rm $(docker volume ls -q) # volumes | |
| # networks | |
| docker_networks=$(docker network ls | awk 'NR > 1 { print $1 " " $2 }' | grep -v 'bridge\|host\|none' | awk '{print $1}') | |
| docker network rm ${docker_networks} | |
| #images | |
| docker rmi -f $(docker images -q) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment