Docker Volumes & Data Management
41%
Data Propagation & Updates
Another scenario that could be interesting to explore is when a container with a volume is running, and then we update the volume from the host. What happens to the container? Will the container see the changes?
# Create the volume if it doesn't exist
docker volume create my-other-vol || true
# Create a container
docker run -it -d --name my_container -v my-other-vol:/data busybox
# Write some data to /data from the container
docker exec my_container sh -c 'echo "Hello from container!" > /data/hello.txt'
# See the contents of the file on the host
cat /var/lib/docker/volumes/my-other-vol/_data/hello.txt
What you will see is Hello from container!. Now, if we update the file from the host:
# Write some data to /data from the hostPainless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Unlock now  $31.99$25.59Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
