Expose fuse mounted inside a docker container
I'm trying to run a docker image for mounting hubic (online storage) and expose that to the host
What is working so far is container mounting the fuse point correctly (to /mnt/hubic
)
When running docker I am attempting to run with volume mapped as /path/on/host:/mnt/hubic
this appears to work ( ie docker makes the directory if it doesn't exist) but the contents never appear. If I enter the container I can see the files from the online storage but the host folder contains nothing
Is there an option I'm missing to allow docker to do this ?
Command I am using to start the container
docker run -v ~/.hubicfuse:/root/.hubicfuse -v /tmp/mounted:/mnt/hubic --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined -it {container_name}
The solution comes from the post s3 mounted inside the container. how to expose it to the host?
In this post is described a solution using glusterFS
, requiring more
permissions for the container. The docker command used:
docker run --cap-add SYS_ADMIN --device fuse -v host_mount_dir:container_mount_dir:shared IMAGE COMMAND
For an error like "Path /foo is mounted on /foo but it is not a shared mount ...", the reason is that the docker daemon runs in different mount namespace than systemd. This is the solution for making it run in the same namespace:
mkdir -p /etc/systemd/system/docker.service.d/
cat <<EOF > /etc/systemd/system/docker.service.d/clear_mount_propagation_flags.conf
[Service]
MountFlags=shared
EOF
And restart the docker daemon.
A remark is that the mount is visible on the host if mounted into a directory
binded by -v
.