How to safely mass delete many chaotic images on the server?

  docker, question

The company’s business has used docker on more than 100 servers in the production environment for more than half a year. However, it has recently been discovered that various images on each server are so messy that is there any way to safely delete them in batches?

Delete stopped containers
docker rm $(docker ps --all -q -f status=exited)

Delete unused mirrors
docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")