Docker内部的FUSE [英] FUSE inside Docker

查看:840
本文介绍了Docker内部的FUSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Docker容器中安装和使用FUSE。我的Dockerfile如下:

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"]

运行安装FUSE的程序时,得到: / bin / fusermount:未找到保险丝设备,请先尝试使用 modprobe保险丝

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

如果我安装了 kmod 并在构建步骤中运行 modprobe保险丝,我得到了错误:

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

modprobe:错误:../libkmod/libkmod.c:557 kmod_search_moddep()无法打开moddep文件'/lib/modules/4.4.104-boot2docker/modules.dep.bin'

我该如何解决?

推荐答案

关于Nickolay的以下答案,-privileged 标志并非严格要求,以用作保险丝。而且,您最好避免为您的容器提供这么多的特权。

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.

您应该能够通过将<替换为-如下所示添加SYS_ADMIN

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

有时这可能不起作用。在这种情况下,您应该尝试调整 AppArmor配置文件或按如下所示禁用它:

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>

最后,如果全部失败,请使用--privileged标志。

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

这篇关于Docker内部的FUSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆