Docker is an open-source containerization platform that allows you to quickly build, test, and deploy applications as portable containers that can run anywhere. In this quick tutorial, we will show you how to remove all unused, volumes in Docker. Also, how to remove one or more volume by providing VOLUME NAME.
Removing Docker Volumes:
1./ Remove one or more volumes
To remove one or more Docker volumes use the docker volume ls
command to find the VOLUME NAME of the volumes you want to remove.
$ docker volume ls DRIVER VOLUME NAME local 1e12af8913af888ba67243dec78419bf18adddc3c7a4b2345754b6db64293163 local jenkins
Once you’ve found the VOLUME NAME of the volumes you want to remove, use the docker volume rm
command followed by one ore more VOLUME NAME. For example, to remove the first volume listed in the output above, run:
$ docker volume rm 1e12af8913af888ba67243dec78419bf18adddc3c7a4b2345754b6db64293163
If you get an error similar to the one shown below, it means that an existing container uses the volume. To remove the volume, you will have to remove the container first.
Error response from daemon: remove 1e12af8913af888ba67243dec78419bf18adddc3c7a4b2345754b6db64293163: volume is in use - [47188935a38a6c3f9f11297f8c98ce9996ef5ddad6e6187be62bad3001a66c8e]
2./ Remove all unused volumes
To remove all unused volumes use the docker volume prune
command as below:
$ docker volume prune
You’ll be prompted to continue, use the -f
or --force
flag to bypass the prompt.
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Conclusion
You successfully learned how to remove all volumes or unused volumes in Docker. Also, how to remove one ore volumes by providing the VOLUME NAME.
What’s Next? You might want to check the following guides: