Best practice for using named volumes

What is the problem you are having with rclone?

I want to run two docker containers:

  1. is rclone
  2. is my service which needs access to an clone mount

I don't need access to any files from the host system so all of it should be done via named volumes and don't clutter my file system.

Unfortunately I run into issues that rclone can't mount into already mounted directories (see 1.57 seems to cause "Directory already mounted, use --allow-non-empty to mount anyway" error under docker)

The solution discussed in this thread is not applicable as I can't prepare the named volume and create a subdirectory in there.

Is there any preferred way of doing it? I thought about overriding the entrypoint and adding the mkdir ... to solve it, but this doesn't feel like a clean solution

Run the command 'rclone version' and share the full output of the command.

Docker image:
rclone/rclone:1.57.0

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

version: '3'

volumes:
  gdrive:

drive:
  image: rclone/rclone:1.57.0
  restart: unless-stopped
  volumes:
    - ./rclone/config/rclone.conf:/config/rclone/rclone.conf:ro
    - gdrive:/mnt/Gdrive
  security_opt:
    - apparmor:unconfined
  cap_add:
    - SYS_ADMIN
  devices:
    - /dev/fuse
  command:
    - "mount"
    - "Gdrive:/photos/"
    - "/mnt/Gdrive"  # i have to change this into /mnt/Gdrive/mount but then the subdirectory does not exist
    - "--read-only"
    - "--allow-other"

The rclone config contents with secrets removed.

[Gdrive]
type = drive
client_id = **secret**.apps.googleusercontent.com
client_secret = **secret**
scope = drive
root_folder_id = **secret**
token = {"access_token":"**secret**","token_type":"Bearer","refresh_token":"**secret**","expiry":"**secret**"}

A log from the command with the -vv flag

2022/03/06 12:47:42 Fatal error: Directory already mounted, use --allow-non-empty to mount anyway: /mnt/Gdrive

or if I apply the solution from the other thread:

2022/03/06 13:07:15 Fatal error: failed to mount FUSE fs: mountpoint does not exist: /mnt/Gdrive/mount

I still had issues when manually creating the directory. My service container was unable to see any data from the Google Drive mount.
Maybe it is related to the missing shared flag.

Going the route described in 1.57 seems to cause "Directory already mounted, use --allow-non-empty to mount anyway" error under docker - #5 by ncw via the mount placed in some user directory works if you start the containers in the correct order: first the rclone, then the service. A reboot which starts both at the same time break this setup.

I switched to the docker plugin which seems to be the most robust solution:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.