docker - 在非特权的基于 Ubuntu 的 Docker 容器中使用 gcsfuse 拒绝权限

标签 docker ubuntu google-cloud-storage fuse gcsfuse

我无法运行 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/

相关文章:

docker - Docker构建dockerfile

redirect - Nginx 非 www 到 www 和 www 到非 www

linux - Apache 不会监听除端口 80 以外的其他端口

python - 通过云函数从云存储中读取数据

python - 使用 Python 的谷歌云存储

docker - 从 GCR (Google Container Registry) 导出 Docker 镜像

amazon-web-services - AWS EKS 上的 Golang REST API 部署因 CrashLoopBackOff 而失败

docker - 为什么我不能将容器附加到 docker 网络?

ubuntu - 如何加快视频转换

python - 无法使用 Python 3 编写的 gzip.open() 将压缩文件上传到云存储