How To Clean Up Used Space by Docker
Using Docker has become very handy to must of us when working with multiple environments. However, one problem that we noticed is the incredible disk usage of it. So in this post I will list useful commands that could help us solving the issue.
First, you must check and remove stopped Docker containers that will no longer be used.
To list this you can run:
After selecting the unused containers, you can remove them with the following command:
The flag -v is used to also delete any associated volume.
Then, following command should be executed
- To delete “dead” containers. (containers with status=dead whose creation failed):
- To delete volumes not associated with any containers ( This usually happens when container are deleted without -v flag of docker rm command):
- To delete images not longer referenced by any tag (
- To delete images not longer referenced by any name:
- To delete temporary files (blobs which were left by some interrupted docker pull):
Note: This files are useful in case we want to resume the docker pull command.
Hope you find this post useful and keep Dockering!