Last active
May 6, 2020 12:05
-
-
Save technokid/aaa76ca7eeb7e531f17255532164439a to your computer and use it in GitHub Desktop.
Docker command
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
#Stop and remove all Docker containers | |
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) | |
#Remove all Docker images | |
docker rmi -f $(docker images -a) | |
#Remove unnecessary images before removing the image: | |
docker rmi $(docker images --filter "dangling=true" -q --no-trunc) | |
#Create Alias | |
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)' | |
alias docker_clean_ps='docker rm $(docker ps --filter=status=exited --filter=status=created -q)' | |
#clean all | |
docker kill $(docker ps -q) | |
docker_clean_ps | |
docker rmi $(docker images -a -q) | |
WARNING! This will remove: | |
- all stopped containers | |
- all networks not used by at least one container | |
- all images without at least one container associated to them | |
- all build cache | |
docker system prune -a | |
#delete builder cache | |
docker builder prune |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment