Several articles have been extremely helpful in understanding Docker's volume and data management. These two in particular are excellent:
- http://container-solutions.com/understanding-volumes-docker/
- http://www.alexecollins.com/docker-persistence/
However, I am not sure if what I am looking for is discussed. Here is my understanding:
- When running
docker run -v /host/something:/container/something
the host files will overlay (but not overwrite) the container files at the specified location. The container will no longer have access to the location's previous files, but instead only have access to the host files at that location. - When defining a VOLUME in a Dockerfile, other containers may share the contents created by the image/container.
- The host may also view/modify a Dockerfile volume, but only after discovering the true mountpoint using
docker inspect
. (usually somewhere like/var/lib/docker/vfs/dir/cde167197ccc3e138a14f1a4f7c....
). However, this is hairy when Docker has to run inside a Virtualbox VM.
How can I reverse the overlay so that when mounting a volume, the container files take precedence over my host files?
I want to specify a mountpoint where I can easily access the container filesystem. I understand I can use a data container for this, or I can use docker inspect
to find the mountpoint, but neither solution is a good solution in this case.