Docker – Obsocuring data by mounting a bind mount or non-empty volume in Docker

docker

What means please that sentence:

If you mount a bind mount or non-empty volume into a directory in the
container in which some files or directories exist, these files or
directories are obscured by the mount, just as if you saved files into
/mnt on a Linux host and then mounted a USB drive into /mnt. The
contents of /mnt would be obscured by the contents of the USB drive
until the USB drive were unmounted. The obscured files are not removed
or altered, but are not accessible while the bind mount or volume is
mounted.

Is very vague to me, someone would please explain us what does mean please ?

Best Answer

It means that if you spin up a docker container, that has a directory /etc/foo with files in it, and do a "docker run ... --mount type=bind,source=/home/user,target=/etc/foo" then the directory /etc/foo in your container will no longer appear to have the container's original files, instead it will appear to have the HOSTS /home/user files.

Related Topic