4. Docker Mount
Here we are going to cover how to preserve data outside our container because when the container exits it destroys all the data inside. Which is the biggest problem? But there are ways to sync data out of the container. Let’s find out.
Volume — inside docker host
- It creates volume automatically if it is not present
- Create volume using command -
docker run — mount src=”$(pwd)”,target=$HOME/app,type=volume webapp:1.0
Bind — outside docker host but on host machine.
- It does not create a directory if not present but will send an error
- Add mount using the command
docker run — mount src=”$(pwd)”,target=$HOME/app,type=bind webapp:1.0
The type parameter itself mentions its approach. Both the approach have their own merits and demerits. In one line volume is crated inside the docker host machine so those are platform independent where host mount is dependent on the host machine so command and paths may differ in second approach.
Read More about Docker ..
All blogs ..