Skip to content

Instantly share code, notes, and snippets.

@technokid
Last active May 6, 2020 12:05
Show Gist options
  • Save technokid/aaa76ca7eeb7e531f17255532164439a to your computer and use it in GitHub Desktop.
Save technokid/aaa76ca7eeb7e531f17255532164439a to your computer and use it in GitHub Desktop.
Docker command
#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