admin管理员组

文章数量:1200972

I'm trying to mount a Google Drive folder as a volume in my Docker container using rclone mount. I've successfully mounted the drive on my Ubuntu 22.04 Docker host at /mnt/gdrive using the following command:

rclone mount gdrive:my-folder /mnt/gdrive --allow-other --vfs-cache-mode writes

My docker run command is:

docker run -d -v /mnt/gdrive:/app/data --name my-app my-image

However, when my application inside the container attempts to write to /app/data, I get "Permission denied" errors.

I've tried addressing this by using the --user flag in docker run:

docker run -d -v /mnt/gdrive:/app/data --user 1000:1000 --name my-app my-image

I determined the UID and GID (1000:1000) by running id myuser (where myuser is the user that runs rclone mount) on the host.

Despite this, the permission issues persist. I've also tried:

  • chmod 777 /mnt/gdrive (as a test, which worked, but is obviously not a solution).
  • Ensuring the user running the Docker daemon has access to /mnt/gdrive.

Here's the relevant output of ls -l /mnt/gdrive:

drwxr-xr-x 1 myuser myuser 0 Jan 1 00:00 .

Here's the output of docker version:

Client: Docker Engine - Community

  • Version: 24.0.5
  • API version: 1.43
  • Go version: go1.20.3
  • Git commit: bc4487a
  • Built: Wed Jul 19 19:22:58 2023
  • OS/Arch: linux/amd64
  • Context: default

Server: Docker Engine - Community Engine:

  • Version: 24.0.5
  • API version: 1.43 (minimum version 1.12)
  • Go version: go1.20.3
  • Git commit: a61e2b4
  • Built: Wed Jul 19 19:22:58 2023
  • OS/Arch: linux/amd64
  • Experimental: false

containerd:

  • Version: 1.6.22
  • GitCommit: 8165feabfd1c64e10692892302c928f1fca647bb

runc:

  • Version: 1.1.8
  • GitCommit: v1.1.8-0-g82b1e90

docker-init:

  • Version: 0.19.0
  • GitCommit: de40ad0

rclone version:

rclone v1.63.1

  • os/version: ubuntu 22.04 (64 bit)
  • os/kernel: 5.15.0-76-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.20.5
  • go/linking: static
  • go/tags: none

I acknowledge the content of this question but it wasn't helpful: How to fix Docker: Got permission denied issue

Note: some specific data and path names are omitted or modified in order to protect privacy of sensitive informations.

I suspect there's something I'm missing regarding user mappings between the host and container, especially with rclone. How can I correctly configure permissions so my container can write to the Google Drive mount?

本文标签: Docker Container Permission Denied accessing rclone mount of Google DriveUIDGID issuesStack Overflow