Docker quickly deletes containers and images in batches

1. Delete images in batches

If you want to bulk delete Docker images, there are various commands available. Here are some examples:

1. Delete all mirrors:

docker rmi $(docker images -q)

2. Delete all untagged mirrors (i.e.  <none> mirrors):

docker rmi $(docker images -f "dangling=true" -q)

Note that depending on your Docker version and setup, you may need to prepend the above command  sudo to get the necessary permissions.

These commands use some of Docker's command options, such as  -q(only display image IDs), -f(filter results) and special filters  "dangling=true"(find all untagged images, why is dangling, still exploring) .

Be careful when executing these commands, as deleted images cannot be recovered. If you just want to clear some space, there are other ways, such as using  the command . This command cleans up unused data. docker system prune

2. Batch delete containers

1. In Docker, you can run the following command to batch delete all running containers:

Guess you like

Origin blog.csdn.net/JineD/article/details/132327910