1

Setup: Over the past week I've been trying to set up a Nextcloud Docker instance on an Ubuntu Server VM, in my old 2015 Macbook Pro using VirtualBox and Vagrant. While the VM only has limited storage for the Nextcloud container, the Docker volume responsible for file storage is located in a shared folder provided by VirtualBox, which is located on a 2TB APFS Seagate drive mounted to the MBP, and the procedure is described in the Vagrantfile as follows,

# /vagrant/Vagrantfile
Vagrant.configure("2") do |config|

  config.vm.box = 'ubuntu/focal64'
  config.vm.hostname = 'ubuntu-server'
  config.vm.network # some network configs
  config.vm.synced_folder '/Volumes/SEAGATE/data/nextcloud', '/media/nextcloud'
  config.vm.provision "shell", path: "setup.sh"

end

in the setup.sh as follows,

# /vagrant/setup.sh
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get -y install docker docker.io docker-compose
sudo docker-compose -f /vagrant/docker-compose.yml up -d

and in the pretty-much-boiler-plate docker-compose.yml as follows,

# /vagrant/docker-compose.yml
version: '3'

services:

  nextcloud_db:
    image: mariadb:10.5
    container_name: nextcloud_db
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - /media/nextcloud/var/lib/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  nextcloud:
    image: nextcloud
    container_name: nextcloud_server
    restart: always
    ports:
      - 8080:80
    links:
      - nextcloud_db
    volumes:
      - /media/nextcloud/var/www/html:/var/www/html
    environment:
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      
volumes:
  nextcloud:
  nextcloud_db:

Note: when the Vagrant instance finishes, I usually reboot the instance to reload the ownership and groups of the Nextcloud server files. This is because these server files will be assigned to root, when they should be assigned to www-data or systemd-coredump. This incorrect assignment leads to certain directories and files such as /var/www/html/data and config.php being unwritable.

However, I've encountered an issue that any account, despite being allocated unlimited storage and therefore should have at least 1TB storage, has its storage limited to the size of the Vagrant instance, which is often < 50GB. This is because while the account data is correctly located in /var/www/html/data in the Vagrant instance, it is not located in the Macbook host in /Volumes/SEAGATE/data/nextcloud/var/www/html/data where it should be. This is despite the fact that on setup, the Nextcloud volume is completely synced on the Seagate drive, which means that at some point after setup the file syncing fails.

To reproduce this: create the instance with vagrant up, reboot the instance, enter the Nextcloud startup page and create the Nextcloud root user. Data for the root user will only be seen in the guest VM and not in the host machine.

Factors: This problem occurs on both Windows and MacOS operating systems, and occurs regardless of whether the shared folder is an external mount, or a local directory. For example, switching /Volumes/SEAGATE/data/nextcloud to some local directory ./local/nextcloud will have the same result. Also, switching to Docker bind mounts does not change the outcome.

I've tried moving the Docker data directory, as well as finding ways to move the Docker volumes in general. There are also previous issues that seem related: External Storage - Folders and Files are not recognized

It's not that I don't have a solution: if the VM were closed off, there would obviously be no problems, because internal syncs are OK. So, my nuclear option right now is to dual boot Ubuntu on the Macbook and install Docker locally to do away with these shenanigans. But that is my last resort. I am more interested in why this problem is happening, because I've never encountered a problem before with folders not syncing.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.