Cleaning Up Left-over Docker Resources
After spending some time hacking with Docker for a blog series, I found that I had a lot of unused Docker containers and images lying around. As part of cleaning up after that, I thought I’d share a few one-liners to remove Docker resources.
Before getting to the one-liners, a quick warning:
The commands below will completely remove all items (containers, images, volumes, etc.) referenced by the command. Make sure you don’t need any of those resources before running these commands.
Removing all containers
docker rm $(docker ps -a -q)
Removing all images
docker rmi $(docker images -q)
Removing all volumes
docker volume rm $(docker volume ls -q)