Skip to content

Instantly share code, notes, and snippets.

@LozanoMatheus
Created December 17, 2020 22:00
Show Gist options
  • Save LozanoMatheus/95c3b85910f139b2905c4f1c2888c6dc to your computer and use it in GitHub Desktop.
Save LozanoMatheus/95c3b85910f139b2905c4f1c2888c6dc to your computer and use it in GitHub Desktop.
Cleaning Docker images, networks, volumes, etc
## Cleaning Docker images, networks, volumes, etc
function flush_docker() {
[[ "${1}" == "all" ]] && local delete_docker_volumes="--volumes"
docker system df
docker rm -f $(docker ps -qa) &> /dev/null
Docker_Prune_All="$(docker system prune --all ${delete_docker_volumes} --force)"
tail -1 <<< "${Docker_Prune_All}"
}
## Cleaning Docker except the volumes
flush_docker
## Cleaning Docker include the volumes
flush_docker all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment