How to run the vfs/refresh command after mounting on docker

What is the problem you are having with rclone?

I don't know how to automagically run the vfs/refresh command inside the container after mounting with docker

I'm mounting using this definition:

rclone-vault:
    image: rclone/rclone:1.56
    container_name: rclone-vault
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - type: bind
        source: ${PATH_MOUNT_RCLONE}
        target: /data
        bind:
          propagation: shared
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - ${PATH_RCLONE}:/config/rclone
      - ${PATH_CACHE_RCLONE}:/cache
    privileged: true
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse
    security_opt:
      - apparmor:unconfined
    command: "mount VaultCrypt: /data --allow-other ...etc"
   

I've read that with docker you can use either command or entrypoint to execute a script after mounting, but since I'm already using command to mount I'm not sure how to approach this now.

If I could somehow run a cmd command from the host machine (ubuntu) using a container as trigger, I could just run the command

docker exec -it rclone-vault rclone rc vfs/refresh recursive=true 'dir=Media/ 

and orchestrate that container to start as the last one, but I know very little of docker and still can't figure out if that's even possible.

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

rclone v1.56.2 <-- I use this one because apparently it was the last one that didn't require the "--allow-non-empty" flag for mounting

  • os/version: alpine 3.14.2 (64 bit)
  • os/kernel: 5.15.0-46-generic (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.17.1
  • go/linking: static
  • go/tags: none

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)

rclone rc vfs/refresh recursive=true 'dir=Media/'

The rclone config contents with secrets removed.

[Vault]
type = drive
client_id = *
client_secret = *
scope = drive
token = {"access_token":"*"}

[VaultCrypt]
type = crypt
remote = Vault:Vault
filename_encryption = standard
directory_name_encryption = true
password = *
password2 = *

Ok, I just did it this way and worked fine, in case someone else is in the same situation:

for the mount container I added hostname: vault as part of the container definition, the --rc flags shown in the command are the only ones I had previously:


rclone-vault:
    image: rclone/rclone:1.56
    container_name: rclone-vault
    hostname: vault
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - type: bind
        source: ${PATH_MOUNT_RCLONE}
        target: /data
        bind:
          propagation: shared
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - ${PATH_RCLONE}:/config/rclone
      - ${PATH_CACHE_RCLONE}:/cache
    privileged: true
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse
    security_opt:
      - apparmor:unconfined
    command: "mount VaultCrypt: /data --allow-other --rc --rc-addr :5572 --rc-no-auth ...etc"



then, created a new container reusing the rclone/rclone image, used the hostname previously specified with the flag
--rc-addr=vault:5572.
I initially tried this three ways:

--rc-addr=:5572
--rc-addr=localhost:5572
--rc-addr=127.0.0.1:5572

neither of them worked, but again I know very little of docker, I know there must be a much better way of doing this, this container did it fine.

rclone-vault-vfsrefresh:
    image: rclone/rclone:1.56
    container_name: rclone-vault-vfsrefresh
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=${TZ}
    volumes:
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - ${PATH_RCLONE}:/config/rclone
    privileged: true
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse
    security_opt:
      - apparmor:unconfined
    command: "rc vfs/refresh recursive=true 'dir=Media/' --rc-addr=vault:5572"
    depends_on:
      - <whatever container you want to make sure is started after your mount>

at the end you can check your logs for confirmation, I see them like this in Portainer:

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