Setting up Object Storage as primary storage for Nextcloud AIO Docker Container

Greetings All,
I am currently deploying a Nextcloud AIO container into a Linode cloud server. I am trying to configure my container to use Linode’s object storage as the containers primary storage for data. I found the support for object storage for direct install very useful → here.

I am setting up my docker-compose file as so but I am stuck on how to translate the Object Storage as primary storage guidance into deployments for the docker container. I tried deploying the docker container to a set directory in my install and then using that as a passthrough for object storage. However, nextcloud didn’t recognize it and just filled the directory instead with the data.

Here is my docker-compose.yml file I’m writing. Any help would be appreciated.

version: “3.8”

volumes:
nextcloud_aio_mastercontainer:
name: nextcloud_aio_mastercontainer

services:
nextcloud:
image: nextcloud/all-in-one:latest
restart: always
container_name: nextcloud-aio-mastercontainer
volumes:
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- 80:80
- 8080:8080
- 8443:8443
environment:
- NEXTCLOUD_DATADIR=/mnt/ncdata # Here is my trouble spot. How do I tell it to use Object Storage?
- NEXTCLOUD_MOUNT=/mnt/

You can mount the object storage via the host. And use the location where it is mounted in here.

Apart feom that, see https://github.com/nextcloud/all-in-one/discussions/1807

Thank you.

I am now getting a weird error. I went ahead and set up my object storage to mount automatically in /etc/fstab
Here is my line for that:

s3fs#[bucket omitted for privacy]/mnt/ncdata fuse _netdev,auto,users,uid=33,gid=0,umask=027,passwd_file=/etc/passwd-s3fs,url=https://[omitted for privacy].com/ 0 0

`

Here is the output of ls -all /mnt/

> total 9
> drwxr-xr-x  3 root     root 4096 Mar 10 17:30 .
> drwxr-xr-x 19 root     root 4096 Mar  9 19:59 ..
> drwxr-x---  1 www-data root    0 Jan  1  1970 ncdata

When I launch the AIO docker container, I end up with this error on the Nextcloud log file.

> now              
> -------------------------------
>  2023-03-10 20:16:16.518735-06
> (1 row)
> 
> + '[' -f /dev-dri-group-was-added ']'
> ++ find /dev -maxdepth 1 -mindepth 1 -name dri
> + '[' -n '' ']'
> + set +x
> chown: changing ownership of '/mnt/ncdata': I/O error
> chmod: changing permissions of '/mnt/ncdata': I/O error
> rm: cannot remove '/mnt/ncdata/this-is-a-test-file': Permission denied
> Installing imagemagick via apk...
> Enabling Imagick...
> Configuring Redis as session handler...
> Setting php max children...
> stat: cannot stat '/mnt/ncdata': Permission denied
> The www-data user doesn't seem to have access rights in the datadir.
> Most likely are the files located on a drive that does not follow linux permissions.
> Please adjust the permissions like mentioned below.
> The found permissions are:
> 
> (userID:groupID permissions)
> but they should be:
> 33:0 750
> (userID:groupID permissions)
>               now              
> -------------------------------
>  2023-03-10 20:16:22.348226-06
> (1 row)
> 
> + '[' -f /dev-dri-group-was-added ']'
> ++ find /dev -maxdepth 1 -mindepth 1 -name dri
> + '[' -n '' ']'
> + set +x
> chown: changing ownership of '/mnt/ncdata': I/O error
> chmod: changing permissions of '/mnt/ncdata': I/O error
> rm: cannot remove '/mnt/ncdata/this-is-a-test-file': Permission denied
> Configuring Redis as session handler...
> Setting php max children...
> stat: cannot stat '/mnt/ncdata': Permission denied
> The www-data user doesn't seem to have access rights in the datadir.
> Most likely are the files located on a drive that does not follow linux permissions.
> Please adjust the permissions like mentioned below.
> The found permissions are:
> 
> (userID:groupID permissions)
> but they should be:
> 33:0 750
> (userID:groupID permissions)

According to the error message, my permissions are wrong. However, I have my umask set to 027 (750 result). This is confirmed by the directory ls -all command which shows the right permissions and user groups applied. 33 is www-data and 0 is root.

Is it possible that the file system of object storage isn’t compatible with this application as described in the error message? Is there a different way to mount it to make the ncdata directory happy when nextcloud writes its test files? Thank you for the help.

Hi, can you add allow_other to the fstab entry, remoubt the block storage, restart the aio containers from the aio interfacs and check if that makes things work?

I tried your steps.
I went ahead and followed the Nextcloud instructions to reset the instance, remounted the object storage with the fstab update, and restarted.
GitHub - nextcloud/all-in-one: Nextcloud AIO stands for Nextcloud All In One and provides easy deployment and maintenance with most features included in this one Nextcloud instance.

Here are the results from the Nextcloud container log.

s3fs#[bucket] /mnt/ncdata fuse _netdev,auto,users,allow_other,uid=33,gid=0,umask=027,passwd-s3fs,url=https:[bucket location].com/ 0 0
              now              
-------------------------------
 2023-03-11 17:42:15.133004-06
(1 row)

+ '[' -f /dev-dri-group-was-added ']'
++ find /dev -maxdepth 1 -mindepth 1 -name dri
+ '[' -n '' ']'
+ set +x
Installing imagemagick via apk...
Enabling Imagick...
Configuring Redis as session handler...
Setting php max children...
Appdata is not present. Did you maybe change the datadir after aio was first started?
See https://github.com/nextcloud/all-in-one#how-to-change-the-default-location-of-nextclouds-datadir
In the datadir was found:
total 5
drwxr-x--- 1 www-data root    0 Dec 31  1969 .
drwxr-xr-x 3 root     root 4096 Mar 10 11:30 ..

Hi, please reset AIO properly amd try again:

Hello,

I figured out a solution to the problem.

Here are the steps I followed.

First, I followed the steps outline in the container reset instructions.

Then I did the following.

  1. After starting the containers in the AIO tab, I allowed Nextcloud to fully start. I did the initial login with the generated admin login and password.
  2. I went into the AIO tab and stopped the containers.

    a. An alternative is to use these commands in an SSH prompt
    sudo docker stop nextcloud-aio-mastercontainer; sudo docker ps --format {{.Names}}; sudo docker stop nextcloud-aio-apache; sudo docker stop nextcloud-aio-nextcloud; sudo docker stop nextcloud-aio-imaginary; sudo docker stop nextcloud-aio-fulltextsearch; sudo docker stop nextcloud-aio-clamav; sudo docker stop nextcloud-aio-redis; sudo docker stop nextcloud-aio-database; sudo docker stop nextcloud-aio-talk; sudo docker stop nextcloud-aio-collabora; sudo docker ps --format {{.Names}}; sudo docker ps --filter "status=exited";
  3. I SSHed into my server as root and copied the /mnt/ncdata directory.
    a. mkdir /mnt/ncdataclone
    b. cp -a -v /mnt/ncdata/. /mnt/ncdataclone
  4. I then mounted my bucket us s3fs
    a. sudo echo "ACCESS:SECRET" | sudo tee /etc/passwd-s3fs
    b. sudo s3fs [BUCKET NAME] /mnt/ncdata -o passwd_file=/etc/passwd-s3fs -o umask=0007 -o uid=33 -o gid=0 -o allow_other -o mp_umask=0007 -o nonempty -o url=https:[BUCKET Provider Link].com
  5. I performed a test to ensure the bucket was mounted.
    a. cd /mnt/ncdata
    b. touch test-doc.txt
  6. I logged into my Object Storage Provider and verified the object was in the bucket. I then deleted the test file using the web interface.
  7. I updated the /etc/fstab file to reflect the mounting options
    a. sudo nano /etc/fstab
    b. I added s3fs#[BUCKET] /mnt/ncdata fuse _netdev,allow_other,passwd_file=/etc/passwd-s3fs,umask=0007,uid=33,gid=0,mp_umask=0097,nonempty,url=https:[Bucket provider link].com/ 0 0 to the last line of the fstab file.
  8. I then copied all the documents from the ncdataclone directory into the new mounted ncdata directory
    a. cp -a -v /mnt/ncdataclone/. /mnt/ncdata
    b. NOTE: After each copy command, I received this error “cp: preserving times for ‘/mnt/ncdata/.’: Input/output error” This error was the error preventing the initial Nextcloud deployment on the object storage mount. Running the Nextcloud deployment on the host and then transferring the files solved the problem.
  9. Once this was completed, I rebooted the server.
  10. After reboot, I logged into the admin account, made a test document in the document folder, and verified the document propagated into the object storage bucket using the bucket web interface.
2 Likes