Fully Automated in Docker

I just went through the exercise of configuring rclone and was surprised there wasn't just a plug and play Docker solution, or a singular guide to get all the pieces working together... so I put one together. Check out my blog post which includes a docker based initializer that will auto-mount your rclone remotes.

Some highlights below from my configuration:

Main Docker Container

  rclone:
    image: rclone/rclone:latest
    container_name: rclone
    volumes:
      - .config:/config/rclone
      - ./logs:/logs
      - ./cache:/root/.cache/rclone
      - /:/hostfs:rshared
      - /var/cache/rclone:/vfsCache
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      - /etc/fuse.conf:/etc/fuse.conf:ro
    devices:
      - /dev/fuse:/dev/fuse:rwm
    cap_add:
      - SYS_ADMIN
    security_opt:
      - apparmor:unconfined
    command: 
      - rcd
      - --rc-web-gui
      - --rc-web-gui-no-open-browser
      - --rc-addr=:5572
      - --rc-user=AGOODUSERNAME
      - --rc-pass=AGOODPASSWORD
      - --log-file=/logs/rclone.log
      - --log-level=DEBUG
      - --cache-dir=/vfsCache
    networks:
      - reverse-proxy-network
      - rclone-net
    environment:
      - TZ=America/New_York
    restart: unless-stopped

Auto Initializer

  rclone_initializer:
    image: ghcr.io/coanghel/rclone-docker-automount/rclone-init:latest
    environment:
      - RCLONE_USERNAME=AGOODUSERNAME
      - RCLONE_PASSWORD=AGOODPASSWORD
      - RCLONE_PORT=5572
      - PUID=1000
      - PGID=1000
    restart: unless-stopped
    depends_on:
      - rclone
    networks:
      - rclone-net

How it Works

The initializer is a simple python script which uses the rclone remote's HTTP endpoint to mount a subset of mounts. It unfortunately requires the user to provide a JSON of mount options since the listmounts api currently only returns fs and mountpoint.

Next Steps

I see some potential improvements that could be made, but they require additional features on the rclone side. I'll do my part and see if there are existing feature requests and if not add them soon.

Improve mount/listmounts API

It would be awesome if the mount/listmounts api endpoint also returned the mountOpt and vfsOpt blocks. This would allow a path forward to capture mounts added through the WebGUI (or otherwise) and save their config.

OAuth 2.0 Flow

I, for the life of me, could not get OAuth 2.0 to work in the WebUI when served on a headless machine behind a reverse proxy. As I started looking into it it appears it might be a limitation since rclone doesn't allow passing the "redirect listening address" the way it allows setting --rc-addr as ":5572" to allow the correct interface bind in a docker network.

At this point, I'm not sure if it's a me issue or a feature to work on.

Final Thoughts

I had a ton of fun getting this all set up, and several community posts here guided me on the journey! Thank you to everyone here and I hope this helps someone in the future.

2 Likes