In the process of compiling child images, docker produces many useless containers and images. To delete these contents, it will be very troublesome to delete them one by one. Therefore, some skills are needed to do this.
1. Query the most recent containers
#Query the last 5 sudo docker ps -a -n=5
2. Only output the id of the container
sudo docker ps -a -q
3. Delete recent containers in batches
sudo docker rm $(docker ps -aq -n=5)
4. Query out the useless mirror
# -f parameter is the filter condition sudo docker images -f dangling=true
5. Delete useless images in batches
sudo docker rmi $( docker images -f dangling=true)