Docker - Remove unused containers images volumes using the docker system prune command

by
Jeremy Canfield |
Updated: June 26 2023
| Docker articles
The docker system prune command can be used to
- Remove all stopped containers
- Remove all Docker networks not being used by any containers
- Remove all images that are not being used by any containers
- Remove all build cache
sudo docker system prune --all
The --volumes flag can be included to remove volumes that are not being used by any containers.
sudo docker system prune --all --volumes
By default, there will be a prompt asking you if you want to proceed. The -f or --force flag can be used to avoid the prompt and go foward with the removal.
sudo docker system prune --all --volumes --force
Did you find this article helpful?
If so, consider buying me a coffee over at