Docker Cleanup

Docker is a great tool, we all know it.
Often, there are consecuences of a rash usage like to have lots of containers, volumes or images hanging around.

Here there are few useful commands to cleanup docker resources.

Remove only exited containers

1
docker rm $(docker ps -a -f status=exited -q)

Remove dead volumes

1
docker volume rm $(docker volume ls -f dangling=true -q)

Remove unused images or volumes

1
docker {image|volume} prune

Remove all containers

1
docker rm $(docker ps --no-trunc -aq)