How to use rclone with nextcloud docker

Introduction

Nextcloud supports external storage. We will be adding to its external storage via this path:

Docker volume plugin --> rclone plugin --> rclone config with remote --> docker-compose.yaml volume section --> docker-compose.yaml services volume mounting section --> nextcloud webUI.

Steps

  1. Create config with whatever backend you want
    rclone config
  2. sudo mkdir -p /var/lib/docker-plugins/rclone/config and sudo mkdir -p /var/lib/docker-plugins/rclone/cache
  3. Copy that conf file into the /var/lib/docker-plugins/rclone/config directory.
  4. docker plugin install rclone/docker-volume-rclone:amd64 args="-v" --alias rclone --grant-all-permissions and sudo docker plugin enable rclone
  5. Add this into the volume section of the compose file for nextcloud. Tweak values as needed.
  ${volume_name}:
    driver: rclone
    driver_opts:
      remote: '${your_remote}:'
      allow_other: 'true'
      vfs_cache_mode: full
      poll_interval: 0
      umask: 000
  • note, I have only tried the umask: 000 option and nothing else. Perhaps something like 776 will work, but too lazy to try.
  1. Mount the volume into the nextcloud service:
    volumes:
      - nextcloud:/var/www/html
      - ${your_remote}:/some_path_you_want
  1. Restart container: sudo docker compose restart
  2. Install nextcloud external storage app.
    Configuring External Storage (GUI) — Nextcloud latest Administration Manual latest documentation
  3. Nextcloud --> Settings --> Administration --> External storage. Add parameters.
    like this

Beware

  • File edit appearances will be slow, but they will happen at the end.
  • Let's hope this post will not be deleted - Creation of a directory called www
  • Have not been met with Transport endpoint not connected error yet when rclone mount is managed via docker plug in, comment below if you have any.
  • You can fiddle with the other settings for performance in regards to vfs, but I don't think there is a need if you are just serving the external storage to be downloaded and uploaded.

Demonstration

$ sudo docker exec -it nextcloud /bin/bash -c 'ls -hal /mounted/path'
total 4.0K
drwxrwxrwx  1 root     root    0 Jun 15 23:02 .
drwxrwxrwx 16 www-data root 4.0K Jun 15 22:59 ..
drwxrwxrwx  1 root     root    0 Jun 15 23:05 Folder
drwxrwxrwx  1 root     root    0 Jun 15 23:13 www

References

https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/external_storage_configuration_gui.html

If you need to make a volume by itself.

I don't think you need to run the php occ command at all, nextcloud will be slower but it will eventually update the external storage.

No amount of work done in a container can change permissions, only the options at the creation of the volume can.

Comment below if you need anything, too bad I am too lazy to write the fold down syntax for the sections.
1 Like