1

I would like to use some functions like fuse (sshfs) in a docker container, which is provided by kernel. I can load the modules easily in docker containers with privileged mode. However, if I would like to load the module when the container start and do not let it load other modules, is it possible?

6
  • How about mounting the sshfs from the host machine and then sharing the mount point to the container? – peterh Dec 26 '18 at 21:32
  • Btw, sshfs is not very good for productive usage, although it might be good if your container isn't a long lived one. For productive usage, I would use davfs. – peterh Dec 26 '18 at 21:34
  • In fact, I am to teach some students about transferring files over internet. It is nature to introduce sshfs when talking about sftp. I would like the students to try in a docker container. – Steven Yang Dec 27 '18 at 4:06
  • Why docker containers instead of openvz instances: It is easier to set up and damage a docker container, and docker containers consume less disk. – Steven Yang Dec 27 '18 at 4:09
  • Ok. sshfs is not a kernel module, it is a fuse filesystem. Fuse is the kernel module. Load in the host machine. Sshfs is a process which interacts with this kernel module, and provides the filesystem for it. – peterh Dec 27 '18 at 5:32
2

Are you sure the problem is actually loading modules? If I do this:

% docker run -it ssh-test bash
root@090961bb6f3a:/project# sshfs xxxx@xxxx:/xxxx/xxxx /mnt

I get

fuse: device not found, try 'modprobe fuse' first

The reason is that Docker containers have restricted capabilities. The way to work around it is to run the container with

% docker run -it --cap-add SYS_ADMIN --device /dev/fuse ssh-test bash

which lets me use sshfs to mount volumes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.