I want to start a docker process so that it could see a folder mounted on the docker host using sshfs.
E.g.: on the host I have ~/external/dir which was mounted via sshfs soemuser@somehost:/somepath ${HOME}/external/dir. I ran sshfs in the same user session where I'm trying to start docker container.
When I start docker process using -v switch to point to the mounted directory I'm unable to access the mounted directory in the container, e.g.:
docker run -it --rm --name test -v "${HOME}/external:/external" busybox /bin/sh
/ # ls /external/
ls: /external/dir: Permission denied
When I try to mount a directory within ${HOME}/external folder I'm unable to start docker container completely, e.g.:
docker run -it --rm --name test -v "${HOME}/external/dir/foo:/foo" busybox /bin/sh
docker: Error response from daemon: error while creating mount source path '/home/aaa/external/dir/foo': mkdir /home/aaa/external/dir: file exists.
Is there a way to somehow mount a folder that itself is sshfs-mounted on the host?
The host OS is linux.
Tried: mounting subfolder, using other docker images (e.g. centos:7).
The workaround is to copy everything from the mounted folder to the host-local folder, but it is very cumbersome due to folder's volume.
You're running into this behavior, documented in the
sshfsman page:And indeed, I am able to reproduce your problem exactly without that option, but if I run:
Then in the container I can access the mounted directory without a problem: