Answer the question
In order to leave comments, you need to log in
How to automatically mount a directory in a docker container when it is mounted in the host?
There is a container with a folder mounted via volume, for example, on the host /opt/project1/, and inside the container - /var/www
docker run -v /opt/project1:/var/www....
On the host, we mount the second disk (sdb1) to the /opt/project1/folder1 folder.
Put any file there.
The container and, accordingly, the application does not see this file. We restart the container and then the file is visible.
Do umount /opt/project1/folder1.
And the container continues to see the mounted disk and its contents until it is restarted.
What to read about this behavior - can anyone come across?
Answer the question
In order to leave comments, you need to log in
If you take a directory, put a file in it, then mount something on this (not empty) directory.
If you have already left the directory, the file will be inaccessible along the path - there will already be a new bind in this place. But after unmounting, the file will be available there again.
So mounting to a folder is not creating a subdirectory, so if you mount something in one container, the other container will not see it.
Mounts are stored in /proc, namely /proc/mounts, and therefore since each container keeps its own /proc, if something is remounted, other containers don't know about it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question