I have docker installation with many containers and running images. I installed it for testing while learning the docker. Now I don't want all these containers and images. I am also tried docker-compose for running images which created many docker images. I want to get rid off all these images and containers.
How to delete all Docker local Docker images?
What is the best command to delete all in one go? After deleting all these I will start using my docker for running some specific images.
Just share me the command to delete all docker local docker images with one command.
There are docker commands to delete all or selected images/containes from docker. You can use any of these command as per your need.
If you want to delete all containers including its volumes the you can use following command:
docker rm -vf $(docker ps -a -q)
If you want to delete all the images the use following command:
docker rmi -f $(docker images -a -q)
Please note that you must remove all the containers before removing all the images in the docker was created. Above two commands wil help you in a) deleting all containers and then b) delete all docker images.
Following easy command can also be used:
Use following command to delete all images:
docker rmi $(docker images -a)
If you want to delete containers which are in exited state then use following command:
docker rm $(docker ps -a -f status=exited -q)
If you want to delete containers which are in created state then following command can be used:
docker rm $(docker ps -a -f status=created -q)
As said above you must first remove all the containers then remove the images from docker instance.
So, I have explained you the commands to delete all docker container and images from docker instance.