Yes you can clean up resources in docker all at once.Docker takes a conservative approach to cleaning up unused objects (often referred to as “garbage collection”), such as images, containers, volumes, and networks: these objects are generally not removed unless you explicitly ask Docker to do so. This can cause Docker to use extra disk space. For each type of object, Docker provides a prune command. In addition, you can use docker system prune to clean up multiple types of objects at once.
The docker system prune command is a shortcut that prunes images, containers, and networks. In Docker 17.06.0 and earlier, volumes are also pruned. In Docker 17.06.1 and higher, you must specify the --volumes flag for docker system prune to prune volumes.
The command is :
docker system prune [OPTIONS]
--all , -a |
|
Remove all unused images not just dangling ones |
--filter |
|
API 1.28+
Provide filter values (e.g. ‘label==') |
--force , -f |
|
Do not prompt for confirmation |
--volumes |
|
Prune volumes |
Here's an example:
![](https://www.edureka.co/community/?qa=blob&qa_blobid=4674104375923745578)