How to delete all stopped containers in Docker
This article mainly shows you "how to delete all stopped containers in Docker". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to delete all stopped containers in Docker".
Method 1:
# display all containers, filter out containers with Exited status, take out ID,sudo docker ps-an of these containers | grep Exited | awk'{print $1}'# query all containers, filter out containers with Exited status, list container ID, delete these containers sudo docker rm `docker ps-a | grep Exited | awk'{print $1}'`
Method 2:
# delete all containers that are not running (those that are already running cannot be deleted, those that are not running will be deleted together) sudo docker rm $(sudo docker ps-a-Q)
Method 3:
# delete the container sudo docker rm $(sudo docker ps-qf status=exited) in Exited status according to the status of the container
Method 4:
After version 1.13 of # Docker, you can use the docker containers prune command to delete orphaned containers. Sudo docker container prune # remove all mirrors sudo docker rmi $(docker images-Q) above is all the content of the article "how to remove all stopped containers in Docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!