Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FUSE inside Docker

Tags:

docker

fuse

I'm trying to install and use FUSE inside a Docker container. My Dockerfile is the following:

FROM golang:1.8  WORKDIR /go/src/app COPY . .  RUN apt-get update && apt-get install -y fuse && rm -rf /var/lib/apt/lists/* RUN go-wrapper download RUN go-wrapper install  CMD ["go-wrapper", "run", "/mnt"] 

When I run the program mounting FUSE, I get: /bin/fusermount: fuse device not found, try 'modprobe fuse' first.

If I install kmod and run modprobe fuse during the build step, I get the error:

modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.104-boot2docker/modules.dep.bin'

How can I fix this?

like image 240
Cydonia7 Avatar asked Jan 23 '18 12:01

Cydonia7


People also ask

Does Docker use fuse?

fuse-overlayfs is preferred only for running Rootless Docker on a host that does not provide support for rootless overlay2 . On Ubuntu and Debian 10, the fuse-overlayfs driver does not need to be used, and overlay2 works even in rootless mode. Refer to the rootless mode documentation for details.

What is Dev fuse?

FUSE Overview. The FUSE device driver is a general purpose filesystem abstraction layer, which loads as a kernel module and presents a virtual device (/dev/fuse) to communicate with a user (non-kernel) program via a well defined API.


2 Answers

With respect to Nickolay's answer below, the --privileged flag is not strictly required, for fuse. And you're best to avoid giving that much privilege to your container.

You should be able to get things working by replacing it with --cap-add SYS_ADMIN like below.

docker run -d --rm \            --device /dev/fuse \            --cap-add SYS_ADMIN \       <image_id/name> 

Sometimes this may not work. In this case, you should try and tweak the AppArmor profile or just disable it as follows:

docker run -d --rm \            --device /dev/fuse \            --cap-add SYS_ADMIN \            --security-opt apparmor:unconfined \       <image_id/name> 

Finally, if all fails, use --privileged flag.

like image 106
Gery Vessere Avatar answered Sep 29 '22 19:09

Gery Vessere


Just as a workaround you can do the modprobe fuse on your host, then using --device /dev/fuse to get the device in the container. Anyway container should be started in privileged mode to mount things with the /dev/fuse.

The command to run the docker image is:

docker run -d --rm --device /dev/fuse --privileged <image_id/name> 
like image 21
nickgryg Avatar answered Sep 29 '22 18:09

nickgryg