Bind Mount Understanding

Hello,
I am using bind mount to access my lustres from docker. My bind path here is /home/ubuntu/lustrefsx.
I mounted by lustre on /home/ubuntu/lustrefsx/34 on the host and stopped all existing containers. For the new containers spinned up /home/ubuntu/lustrefsx/34 was accessible and working.
Now in the screenshot if we see I unmounted my lustre from the host instance but is still accessible in the docker container. Is this an expected behavior.?
if yes, can you shed some more light on what’s happening here.

HI, I think this is the normal behavior.

When you bind mount a local file from your host to a docker container than the container actually uses the inode to mount that file (it is just my experience) so even if you delete the file on the host, the container still sees it because it has its own reference to that inode on the filesystem so the file is not completely deleted yet.

I guess it could be similar with a network filesystem. Your directory on your host is just a reference to the network filesystem. When you mount the target directory to your container, it will not mount the directory itself but the network filesystem directly.

You can see the mounts if you exec into the container and run “mount” without parameters. Or directly with docker exec

docker exec -it yourcontainername mount

My output contains this:

//ta-lt/Users/phppr/dockertest on /data type cifs (rw,relatime,vers=default,cache=strict,username=phppr,uid=0,noforceuid,gid=0,noforcegid,addr=172.18.224.1,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=1048576,wsize=1048576,echo_interval=60,actimeo=1)

“ta-lt” is the hostname of my windows where I shared a folder.

You will still see the local directory’s path when you run docker inspect because that was the original definition:

        "Mounts": [
            {
                "Type": "bind",
                "Source": "/mnt/test",
                "Destination": "/data",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],