Mounting a remote network directory shared by sshfs to docker containers in WSL
Let's say I am running a docker container in WSL and a remote source directory is mounted to a WSL target directory by sshfs. And I want to mount the sshfs shared folder to the docker container.
When I first tried this, I used the following command to mount the remote source directory
sshfs <remote server name>:<source directory in the server> <target directory in WSL>
and ran docker image as if sshfs shared directory is just a local directory.
docker run -v <target directory in WSL>:<target directory in docker container> <docker image name>
But in this case, target directory in docker container was empty without any error message.
So I searched through the google about this problem and the suggested solution was
https://serverfault.com/questions/947182/mount-a-sshfs-volume-into-a-docker-instance
However, it didn't work either.
Fortunately, with some trial and error, I found out that I need to use '-o idmap=user' option with the above sshfs command. So, it becomes
sshfs -o allow_other -o idmap=user remote_server_name:<source directory> <target_directory>
And it works fine.
I still don't know if this is a wsl specific problem or it generally happens in linux environments.
댓글
댓글 쓰기