"Can't create or write into the data directory" error with docker, docker-compose, and external drive

Hardware: Raspberry Pi 4 4GB booting OS from 80GB SSD connected to USB 3.0
OS: Ubuntu 20.04 64 bit for ARM
Data drive: 4TB SSD connected to USB 3.0
Installation method: docker-compose

I am using the example docker-compose file from the docker hub site to run behind my nginx proxy:

version: '2'

volumes:
  nextcloud:
  db:
  data:

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
      - data:/media/usb-drive/ncdata
    environment:
      - NEXTCLOUD_DATA_DIR=/media/usb-drive/ncdata
    restart: always

When I go to my local IP address and choose “/media/usb-drive/data” in the field to store my data on the configuration page, I get the error: “Can’t create or write into the data directory /media/usb-drive/ncdata”. My normal unprivileged user can write to the data folder on the drive no problem. If I just leave it as default, the installation succeeds, but the data folder is then on the main OS drive which I do not want.

What do I need to add to my docker-compose.yml to get this to work correctly and where do I need to add it?

Same issue here - permissions are identical and the host data dir’s been created prior to composing. I think the container user that the process runs under is different to root - it’s www-data or something. Untitled Untitled .
I think you could do something under /var/www but not outside that code here

Rats.Untitled Untitled