【发布时间】:2021-04-19 06:34:50
【问题描述】:
我无法使用 --cap-add SYS_ADMIN --device /dev/fuse 在基于 Ubuntu 的 Docker 映像中运行 gcsfuse,如其他帖子中所示。
不过,它对--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
我错过了什么吗?谢谢
【问题讨论】:
-
您是否尝试了另一个目录而不是
/root?比如/tmp作为根目录 -
是的,我做到了,但它也不起作用。
标签: docker ubuntu google-cloud-storage fuse gcsfuse