Docker Community Forums

Share and learn in the Docker community.

DO I understand volumes correctly when mounting a volume over an existing directory


(Ralph Kincade) #1

say I create a volume
"docker volume create --name test_VOL_34"

and then run and mount a container to it with

docker run -it -v test_VOL_34:/my_folder ubuntu:14.04 bash

from in the container I create a file in the /my_folder directory

I save that to and image

then run a container from that image , when it runs it will mount the my_folder directory

I know I wont see the file as it was in a volume and data inside a volume is not saved to the image

but I am connecting to that volume and I can see the data outside the volume

what is a good way to describe this behavior ?

“I see this comment If you mean that you’re mounting a volume over an existing directory, and expecting to see the files from the existing directory… you wont.”

I am trying to expain this to people here and having some trouble , can you confirm that this is expected behavior and if you want to add comments or reword the explanation

I just want to be clear on this before I open my mouth and attempt to expain this here

thanks