Is a new Nextcloud Docker container keeping data and settings?

I am just getting started with Docker and have a few basic questions.

I am using a Synology DS420+ with Nextcloud 22.2.0 in a Docker v20.10.3 container with MariaDB 10 v10.3.29 (DB not in the Docker container, but the Synology package). All basic functions are working and I don’t want to put that at risk by trying to configure in the container’s terminal (e.g. adding SVG support in the php-imagick module). In a VM, I would create a snapshot…

If something went wrong and I have to delete the Nextcloud container and create a new one with the same settings (volume, port settings and environment variables), will it find the data in MariaDB 10 or do I need to recreate/sync calendars and address books? Do the names of the old and new containers have to be identical? I assume I have to set user accounts and settings (admin) again or have I overlooked an export and import function for this?

Does anyone know what the difference is between restarting and resetting? Or is restart just the same as stop & start?

I’m not familiar with Sinology way of doing things but in general Docker is working exactly as you want - put all persistent data on specific volume (or more correct other way round: mount volumes into every place in container you want to keep) and configure everything you need like DB connection using environment variables - then you don’t need to worry about the container itself - it’s always possible to drop and re-create the container from scratch…

but I would recommend you to test and write down the procedure you need before you start using it for production data. just try it out: place some files into the instance, install additional apps, create calendar items, then remove your container and create a new one using same settings - if it works you know what to do - if you miss something you know you missed something important you want to have to keep. I recommend you to test an upgrade as well (start with previous NC version and upgrade to the current)…

and try backup/restore - you need both data and DB backup at the same time to be able to recover your system… and store the backup outside of your original system to cover hardware failure and malware attacks…

Thank you! That sounds simple.

I have not yet dealt with backups and restores in detail. The administration manual says very little on the subject. Can’t I do backups from Nextcloud using the GUI?

I’ve only seen instructions for the console, and I’m always unsure of the quality of those. Besides, I don’t know how to adapt them for my installation. It is even worse with scripts for automation. Do you have a tip which tutorial I should look at?

there are shorter videos. but i think this is a good one:

wrong mindset. it is the nature of containers to be deleted and recreated from the image. e.g. that’s way you get updates. to nextcloud,php, apache/nginx and what else is in the image and needs an update.

may you post the list of the volumes you created? it should this list.


or the volumebindings: [] if you export the container settings.

if that contains something like <path-to-synology>:/var/www/html then you are save. because your complete nextcloud data and config is persistent. (unless you didn’t do other stupid thing. :wink: )

your backup should contain <path-to-synology> plus the database dump.

( i don’t know the <path-to-synology> looks like because i don’t run container on my synology. sorry.)

restarting should do “stop & start” of all processes in the container. i guess resetting destroys the container and recreates it from the image. that would be needed in case of an update.

1 Like

Starting the Nextcloud container was quite simple:

Volume: docker/nextcloud
MountPath: /var/www/html/ (rw)

Volume: /NextcloudSync/Data 
MountPath: /data/ (rw)

Network: bridge

local port: 6080
container port: 80

MariaDB 10 is not installed in a container but as a synology package.

In /docker/nextcloud 850 MB are stored, /NextcloudSync/Data is empty.

Does this mean that not only the Nextcloud data but also the configurations inside Nextcloud (included calendars and contacts, users, settings) are stored outside the container?

look at docker/nextcloud/data there should be a folder for each user.
look at docker/nextcloud/config.php this is the config. it should include your db settings. server, port, password, etc.

did you create /NextcloudSync/Data (for a specific purpose)?

…and the user folder contains the folders files and cache.

However, I don’t see my content, contacts and calendar (or anything that looks like a database) there.

I have already noticed that dbpassword and mail_smtppassword are stored there in plain text, but I guess I can’t change that.

This was recommended to me by a patient user of The “data” directory would be synchronization with the Nextcloud client there. Since I do not use Nextcloud (so far) for file hosting, I am not surprised that the directory is empty. Until now I use Nextcloud only as a CalDAV/CardDAV server.

all your contacts and calendar item are stored in the database. as far as i know.

nextcloud store files (and some metadata) in /var/www/html/data.

So, going back to the original question, can I calmly delete the Nextcloud container and set it up again regardless of the conainer name?

Two containers Nexcloud1 and Nexcloud2, which access the same volumes can exist but should not run simultaneously?

So I could stop the existing Nextcloud container, create a new one, change configurations in it (currently I want to try to install SVG support in the php-imagick module with apt install libmagickcore-6.q16-6-extra) and in case of failure just delete the new container and start the old one again?

Or does apt install libmagickcore-6.q16-6-extra put the changes into docker/nextcloud/?

Excuse me for asking but I am still unsure.

you have been given the answer multiple times. your questions clearly show your are not familiar with basic concepts of docker… which is not bad as long you take the hints and keep learning… but keep asking same questions again and again is really impolite!

first. never think about login to a container and run apt install. that’s possible but a complete antipattern in the container world. you may do this for testing. but that’s not the way to run container.

second: you can’t start an old container. by resetting you delete the container and start a new one from the image. your data stored in the volumes and in the database are not affected. only your changes to files outside /var/www/html are deleted.

third: as said before. you want to update your conatiner. because you want to get all the security updates and new nextcloud features. so deleting your container and geting the new image provided by nextcloud gmbh is a routine. each time you would have to login the container and run apt install

forth: to install libmagickcore permanently you would have to start building your own images that is kind of simple. but i doubt that it’s worse to maintain your own image.

p.s.: here nana is explaining what you need to know about building docker images:

1 Like

@wwe : I am sorry that I am rude in your eyes. And of course I don’t want to bore anyone by repeating myself.

Perhaps I have expressed myself inaccurately.

Let’s say I stop container Nextcloud1 (no reset) and start container Nextcloud2 from the same image (or a new image after an update). Then I notice that something is not working with Nextcloud2. Can’t I then stop Nextcloud2 and start Nextcloud1 again - as if I were going back to a previous snapshot in VirtualBox?

OK, got it.

So I should take care of installing the SVG support in libmagickcore on the Synology NAS.

I really appreciate your patient help.

you can do this. i guess it would work.

but that’s not the docker way. the image is the snapshot. you don’t keep container as snapshots.

in a docker world: you create an image (or take the one from nextcloud gmbh). from image you start a container. if somethings wrong you stop the container, change the image build file, build a new image and start it again.

that won’t help you. because it’s not available in the container.

I always try to be clear - maybe you did find my words offending. Please take the time to watch the videos people shared with you. I suppose it helps you to understand what @Reiner_Nippes tried to explain you multiple times without success - and it helps you with your upcoming Docker projects (or maybe show Docker is not the technology you look for…) …maybe you need to watch the tutorial twice or maybe you find a better one - there are lot of Docker 101 explanations - but please take the time and familiarize yourself with docker concepts and come back with questions related to Nextcloud…

Indeed, it’s on you. I wrote myself a little script which does the customization after a new container is created.
To get rid of the libmagic warning I run:

docker exec -it --user root nextcloud-app apt update
docker exec -it --user root nextcloud-app apt -y install imagemagick

nextcloud-app is the name of my container, yours may be different.