I was not able to run gcsfuse
in my Ubuntu-based Docker image with --cap-add SYS_ADMIN --device /dev/fuse
, as seen in other posts.
It works like a charm with --privileged
though, and with root or non-root user. But I would like to avoid this option.
My 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
My test:
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
In the running container:
mkdir /root/gruik
gcsfuse bucket_name /root/gruik/
The result:
Using mount point: /root/gruik
Opening GCS connection...
Mounting file system...
daemonize.Run: readFromProcess: sub-process: mountWithArgs: mountWithConn: Mount: mount: permission denied
Am I missing something? Thanks