How to Delete Local Docker Volumes
Here is a quick guide on deleting a Docker volume from the terminal.
List all Docker volumes
Let's first start by listing all our volumes.
You can do this using the docker volume ls
command.
docker volume ls
This will give you a list of all volumes and some information about them. The first column is the DRIVER
, and the second is the VOLUME NAME
. You'll need the VOLUME NAME
for the next steps.
Remove the Docker volume
To remove a volume, use the docker volume rm
command.
docker volume rm <volume-name>
I hope it's obvious, but just for clarity, replace <volume-name>
with your volume's name.
BE CAREFUL! You should only delete a volume if you are sure no data is needed. Once deleted, the data cannot be recovered.
Delete all unused volumes
If you want to delete all unused volumes (not attached to any containers), you can use the prune
command:
docker volume prune
You will be asked to confirm the deletion. Again, once deleted, the data cannot be recovered.
Since I often need to remember to delete my volumes and had to yet again Google recently, here's a guide for you and future forgetful me.
Follow me on Twitter or connect on LinkedIn.
🚨 Want to make friends and learn from peers? You can join our free web developer community here. 🎉