Like some others, I have separate storage and compute servers.
The data directory is an NFS share on my storage server and I run Nextcloud in docker on my compute server.
I have the NFS share defined as a volume of type nfs in the docker compose, mounted to /var/www/html/data. Nextcloud itself just treats it like a local directory.