External HDD usage with Docker container - Possible?

Hi all,

I’ve got a small NextCloudPi set up on a Pi3 under HypriotOS and docker, and it’s running fine on the SD card itself.

However what I’d like to do is store the files/database on an external hard drive (ext4 formatted partition) which I have connected to the Pi. Looking at all the online info I see references to nc-automount and nc-datadir, neither of which seem to be available from the web panel GUI on my system?

Also if I run the wizard under the webGUI panel, I have the option for USB configuration, but if I select yes to do it and then continue (the drive already being plugged in) I get a box appear in the bottom-right corner of the screen saying nc-automount.sh read error, plus an empty white box on the left hand side of the screen.

Is it possible to do the USB storage with this set-up, or is it restricted to just the SD card?

For reference it’s a fully updated system, using the ownyourbits/nextcloudpi-armhf container running version 0.53.30.


This is now possible, but I just pushed a lot of changes to the docker container and I am currently documenting them.

You can use any folder when you run the container, something like docker run ... -v /media/USBdrive/ncdata:/data ...

Up until now, the proposed solution was to move the docker datadir as explained here, which is something that I would recommend anyway.

Also, if you format BTRFS you will be able to use the BTRFS specific features, such as snapshots and snapshot sync

Also the container is now able to update itself, just like the SD card version.

Thanks - that seems to have worked :smiley:

Ended up running with

docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/cloud/ncdata:/data --name nextcloudpi --restart=“unless-stopped” ownyourbits/nextcloudpi-armhf

By doing it this way can we use any format of drive as it’s just mirroring to a mount point? I recall when I tried this before somewhere it told me that I couldn’t use an NTFS drive as it didn’t support the required user permissions?

In any case I’ve split the drive in two now and one part is NTFS (for my plex server database and media, so I can update it directly from my Windows machines) and the other is ext4 (for NextCloud).


Still it is not a good idea to use NTFS, and I think that NC won’t let you run it like that.

@nachoparker - I need to come back to this one. I’ve set things up as per the docker run command above, but I’m still wondering if the files in my set-up are still actually stored on my SD card rather than on my USB drive?

If I attach a terminal to the container and browse in the /var/www/nextcloud/data folder inside it, I can see sub-folders for all my NCP users, and inside those what looks like the file structure for them. Hence I’d just like to confirm whether setting up the volume -v /media/cloud/ncdata:/data in the docker run command is correct (where the folder in media is the mount point for the USB drive), or should that /var/www/nextcloud/data folder (or something along that tree) should be mapped out onto the USB drive?

I’d like to be able to map a drive in Windows Explorer to see and manipulate the files, but of course if they’re inside the container I can’t do that easily. But equally if the files are being stored on the SD card, it’s obviously not what I want as I want them to actually be on the USB drive.

Is my set-up incorrect, or am I misunderstanding something? And what exactly is getting stored on the USB drive by the mapping of the data volume?

The /data folder that gets mapped isn’t the same as the /var/www/nextcloud/data folder, at least from what I can see? Is the wrong folder mapped in the docker run command?

Have you checked the contents of /media/cloud/ncdata? your data should be there

/var/www/nextcloud gets mapped to /data/app, so not only your files, but your whole instance is mapped to persistent storage

@nachoparker in the ncdata folder I have sub-folders app, database, etc and ncp.

However the app folder beneath it seems to be empty if I look via samba at the folder. If I try and access it via ssh into the overall OS, I get permission denied if I try and enter the app folder. The app folder seems to be owned by www-data, and if I go into it as root (via sudo -s) I can see the data sub-folder and the users folders and files below that (as expected from your comment).

So looks like there’s a user permission issue here. Do I need to add my user to some group or some other tweak (it’s already a member of its own name group plus www-data, video, users, input and docker groups). Or if I chown the folder, will that work or will it break things in NCP? Or should I just adjust privs via chmod?

I’d appreciate your guidance as I’d like the access but don’t want to break things as I’m still finding my feet under Linux… :wink:

maybe this will help

1 Like

Yup, just what I needed.

Samba working fine now :wink: