我无法运行 gcsfuse
在我基于 Ubuntu 的 Docker 镜像中,使用 --cap-add SYS_ADMIN --device /dev/fuse
,如其他帖子中所见。--privileged
的作用就像一个魅力。但是,并且使用 root 或非 root 用户。但我想避免这个选项。
我的 Dockerfile:
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y gnupg lsb-release wget
RUN lsb_release -c -s > /tmp/lsb_release
RUN GCSFUSE_REPO=$(cat /tmp/lsb_release); echo "deb http://packages.cloud.google.com/apt gcsfuse-$GCSFUSE_REPO main" | tee /etc/apt/sources.list.d/gcsfuse.list
RUN wget -O - https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get update
RUN apt-get install -y gcsfuse
我的测试:docker run -it --rm \
--device /dev/fuse \
--cap-add SYS_ADMIN \
-v /path/in/host/to/key.json:/path/to/key.json \
-e GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json my_image:0.1 /bin/bash
在运行容器中:mkdir /root/gruik
gcsfuse bucket_name /root/gruik/
结果:Using mount point: /root/gruik
Opening GCS connection...
Mounting file system...
daemonize.Run: readFromProcess: sub-process: mountWithArgs: mountWithConn: Mount: mount: permission denied
我错过了什么吗?谢谢
最佳答案
这实际上是 docker 本身的一个问题,您需要在 --privileged
中运行您的 docker 容器。模式来实现这个功能。检查此related docker issue
关于docker - 在非特权的基于 Ubuntu 的 Docker 容器中使用 gcsfuse 拒绝权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65715624/