Infrastructure 2019-04-28

Note on Volumes Not Being Deleted Even After Removing Docker Images and Containers

Learn why Docker volumes persist after removing containers and images, how to inspect and remove orphaned volumes with docker volume ls/rm, and the shortcut docker-compose down --rmi all -v.

Read in: ja
Note on Volumes Not Being Deleted Even After Removing Docker Images and Containers

Overview

I often forget that volumes are not deleted even after removing containers and images in Docker, so I'm writing this note.

I usually use docker-compose.

docker-compose build docker-compose up -d

Then, I clean up with:

docker rm ** docker rmi **

However, it seems there is an option to delete mounted volumes.

Solution

Check if volumes remain. docker volume ls

docker volume rm **

Additional Notes

There is a way to clean up all containers, network images, and volumes described in docker-compose.yml at once using docker-compose.

docker-compose down --rmi all -v

References

Tags: Docker Docker Compose
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles