Docker Volume and Storage Notes
Docker Volumes
Docker volumes are used as persistent storage for containers to allow data to be stored even if those containers are stopped or deleted. This type of storage is separate from bind mounts and tmpfs mounts.
Bind mounts are another form of persistent storage for docker containers. They depend on the host machine’s file system and OS, while volumes are “completely managed by Docker” (Sharma, 2024). Meanwhile, tmpfs mounts are non-persistent, only stored in the host’s memory, and used for temporary storage.
I found the following image below to be helpful for visualizing these 3 types of storage for Docker containers:
(Abbas, 2024).
Pantry Analogy for Docker Volumes
Another helpful way to think of Docker volumes is by imagining them as a pantry. Docker volumes exist outside of containers in a similar way to how pantries are separate from kitchens. Plus, the ingredients in pantries can be used for different recipes, and they still remain even if the kitchen is not in use. Similarly, volumes are persistent storage that can be used by multiple different containers (Bakare, 2024).
References
- Abbas, 2024. Medium - Docker Volumes Expained
- Bakare, 2024. dev.to - Docker Basics with Analogies
- Sharma, 2024. AWS Community - What is Docker Volume