Docker Volumes
- When do we need Docker volumes ?
- What is Docker Volume ?
- 3 Volume types
- Docker Volumes in Docker compose file
============
Volumes :
On the host there will be a Physical File system path and we plug into the docker container. So what happens is when the container writes it to its file system it get replicated to the physical file system. If i change somerthing on the physical file system gets replicated the containers as well - it works Vice-Versa
First type: Host Volume:
This type will give you the right to decide which volume on the host file must be used.
docker run -v /home/mount/data:/va/lib/mysql/data
/home/mount/data -- Host directory
/va/lib/mysql/data -- Container file system
---
Second type - Anonymous volumes
just by specifying the container filesystem which host file should be mounted is taken care by docker itself so that directory is automatically created by docker
Second type - Anonymous volumes
just by specifying the container filesystem which host file should be mounted is taken care by docker itself so that directory is automatically created by docker
docker run -v :/va/lib/mysql/data
here you are only referencing the container directory that's taken care of the docker itself
Third Type is an improvement of anonymous volumes -- Named Volumes
it specifies the name of the host file system and the name is up to you it just reference the directory.
it specifies the name of the host file system and the name is up to you it just reference the directory.
docker run -v name:/va/lib/mysql/data
The one you should be using in Production is Named Volumes

Comments
Post a Comment