0

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

Pascal GILLET
  • 135
  • 1
  • 14

1 Answers1

1

This is actually an issue in docker itself and you need to run your docker container in --privileged mode to achieve this functionality. Check this related docker issue

Methkal Khalawi
  • 2,368
  • 1
  • 8
  • 13