Docker Commando's

Clean resources

docker system prune (images, containers, volumes, and networks…)

docker system prune -a (also stopped containers!!!)

Removing Docker Images

docker images -a (show list)
docker images -f dangling=true (List dangling images)
docker images -a | grep “pattern” (specific images)

docker rmi Image Image (Remove specific)
docker images purge (remove all (dangeling) images)
docker images -a | grep “pattern” | awk ‘{print $3}’ | xargs docker rmi (Remove)
docker rmi $(docker images -a -q) (remove all images)

Removing Containers

docker ps -a (list all containers)
docker ps -a -f status=exited (list exited containers)
docker ps -a | grep "pattern” (list specific)

docker rm ID_or_Name ID_or_Name (Remove specific container)
docker rm $(docker ps -a -f status=exited -q) (Remove exited containers)
docker ps -a | grep “pattern” | awk ‘{print $3}’ | xargs docker rmi (Remove specific)
docker stop $(docker ps -a -q) | docker rm $(docker ps -a -q) (remove everything)

Removing Volumes

docker volume ls (List volumes)
docker volume ls -f dangling=true (list dangling volumes)

docker volume rm volume_name volume_name (remove specific volume)
docker volume prune (Remove dangling volumes)