Docker Community Forums

Share and learn in the Docker community.

Make mount point accesible from container to host - rshared not working

Hi everyone,

I am currently running Docker for Windows (3.3.2 – wsl2 support being enabled) and my goal is to be able to mount dd-images inside a container (linux) and make the mount point accessible to the host. Therefore, the host can access the files.

Everything works as intended inside the container which is started with the following parameter:

docker run --cap-add SYS_ADMIN --cap-add MKNOD --device /dev/fuse --privileged=true --mount type=bind,source=/c/Data,target=/data,bind-propagation=rshared -it fedora-forensics /bin/bash

After attaching a dd image to a loop device and mounting this loop device to /data/mount, I can see the content of the partition in /data/mount from inside the container. From the host the folder “c:\Data\mount“ is empty. I did not get any errors.

Then I deactivated the WSL2 support and suddenly got the following error when executing the above docker run command:

docker: Error response from daemon: path /host_mnt/c/Data is mounted on /host_mnt but it is not a shared mount.

Now I am somehow stuck. Is it even possible to make mounts from the container accessible to the host via shared folders? Meaning the bind option shared or rshared to not work on Windows?

Btw using samba is not an option due to port issues…

Kind regards,
Dennis

1 Like

Not sure if you managed to solve this but I just ran into this issue and the fix for that is making your /host_mnt mount as shareable. You can do this by running:

sudo mount --make-shared /host_mnt/

You can also make it rshared or rslave.

For more info, check out the redhat’s docs: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/sect-using_the_mount_command-mounting-bind

1 Like

To verify if your mount is shared, you can run:

findmnt findmnt -o TARGET,PROPAGATION /host_mnt

Or, if your machine doesn’t have findmnt for some reason, you can cat /proc/1/mountinfo | grep shared and make sure that /host_mnt shows up in there.

I should also mention, to persist this change across reboots, you can add shared option to your mount point in /etc/fstab file.