delete all containers
1. First, you need to stop all running containers
docker stop`docker ps -a -q`
docker ps -a -q means to list all containers (including those that are not running), and only display the container number, where
-a : Show all containers, including non-running ones.
-q : Quiet mode, only display the container number.
2. Delete all containers, change the stop in the above command to rm:
docker rm `docker ps -a -q`
remove all images
docker rmi `docker images -q`
docker images -q means to list local images, only displaying the image ID; docker rmi means to delete one or more local images.
Remove images by condition
Delete untagged images (i.e. mirror dangling images whose TAG is none)
docker rmi `docker images -q | awk '/^<none>/ { print $3 }'`
You can also use the following command to delete
docker rmi $(docker images -q -f dangling=true)
Delete images containing a keyword
docker rmi --force `docker images | grep test-api | awk '{print $3}'` //其中test-api为关键字