How can I make AIO docker config changes survive an update

I’m using NextCloud AIO.
I have successfully added the env entry for NEXTCLOUD_MOUNT=/export
and added a volume pointing at /export inside the docker container.

This all works as expected, My NextCloud now can see directories under /export, which I have given access to the users.

However, every time AIO gets updated, these changes get blown away!

I believe that the master container is the one that rebuilds all the other docker containers on an upgrade/update.

Where can I add customizations so that when they get rebuilt, my customizations don’t get lost?

Hi, see GitHub - nextcloud/all-in-one: 📦 The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.

OK; For those who follow my footsteps…

To get an NFS mount persistently presented within NextCloud…

Get the NFS mounts onto the base machine that docker is running on

create the mount points
EG:
mkdir -p /nfs-mount/MyStuff /nfs-mount/More-Stuff /nfs-mount/Other-Stuff

Add the mounts to the fstab

nfs-server:/nfs-volumes-path/stuff/MyStuff        /nfs-mount/MyStuff      nfs defaults,ro,intr    0 3
nfs-server:/nfs-volumes-path/stuff/More-Stuff     /nfs-mount/More-Stuff      nfs defaults,ro,intr    0 3
nfs-server:/nfs-volumes-path/stuff/Other-Stuff    /nfs-mount/Other-Stuff    nfs defaults,intr       0 3

make sure systemD knows bout it

# systemctl daemon-reload
# mount -a
# df -h

Verify the NFS mounts are OK, you should be able to see the files under the mount

Please note … two of these mounts are mounted Read-Only, the only mount that NextCloud will be able to write into is the Other_Stuff mount.
The docker container will need to have write permissions into the directory
so

chown -R www-data:www-data  /nfs-mount/Other-Stuff

On Debian I had issues where docker started before the NFS mounts were properly loaded, so…

systemctl edit docker.service

And add …

[Unit]
Requires=docker.socket
After=nfs-mount-MyStuff.mount
After=nfs-mount-More-Stuff.mount
After=nfs-mount-Other-Stuff .mount
After=network-online.target docker.socket firewalld.service containerd.service nfs-client.target

I also had to edit the /usr/lib/systemd/system/docker.service

vi  /usr/lib/systemd/system/docker.service

and make the After line look like this

After=network-online.target docker.socket firewalld.service containerd.service nfs-client.target

Its the nfs-client.target thats important to make sure NFS is properly running before docker gets going

systemctl daemon-reload

Reboot the VM or LXC container & verify the mounts are now available

Now we need to get the NFS mounts into the docker containers themselves
You need to make the next change on the nextcloud-aio-mastercontainer container (I use portainter, but you can either use the command line or other tools here)

The trick is to get the following ENV value into the MASTER container config

NEXTCLOUD_MOUNT = /nfs-mount

You will now need to log into next cloud web-ui and go to Administration section and get to the AIO interface
EG:

https://nextcloud.yourdomain.org/settings/admin/overview
  • Click on the “Open Nextcloud AIO Interface”
  • Stop all the containers by clicking the “Stop Containers” button
  • Once all the container have shut down they can be restarted via the “Start Container” button

Once they have all restarted, you should see that the NEXTCLOUD_MOUNT variable that you added to the MASTER container is now also on the nextcloud-aio-nextcloud container that actually runs your NextCloud instance.

If you log into the shell for that container
From the docker host itself

# docker exec -it nextcloud-aio-nextcloud /bin/bash
0ff123456:/var/www/html# ls -al /nfs-mount

The files on the NFS mount should be available from within the nextcloud-aio-nextcloud container

Now you can add them as an external storage

  • Go to the Administration page
  • Then click External Storage button
  • Then add the folders

Once this is done, the External folders should appear for the users you have added in the available for selection.

One last step, You will notice that the files you can see via the OS and Docker command line are missing from the NextCloud file browser.
You need to tell NextCloud to scan the directories
So from the docker host again

docker exec -u www-data nextcloud-aio-nextcloud php /var/www/html/occ files:scan --all --no-interaction -vvv

This will take some time if you have many files on the NFS mount
But after this you should have all the files available in the file browser. Further upgrades, backups etc should keep these settings

Good luck & enjoy

1 Like