What folders from docker image need to be persisted?

I have a Docker image set up to use S3 as primary storage and PostgreSQL for the database. For backup reasons what directories within the image should be persisted.

And is possible to spin up a new container that has access to the same data without overwriting it.

Yes, using volumes. Volumes are a mounted location on the host filesystem. You can read more about what volumes are in docker documentation or something like https://www.howtogeek.com/devops/what-are-docker-volumes-and-how-do-you-use-them/

Volumes exist outside of the image, but are defined as part of your run command or compose script so the image will use these locations for persistent data storage.

*Volumes are just as important as images in understanding how container systems such as Docker work. :grin:

1 Like

I am familiar with volumes, I guess I should have been more specific in asking: which directories within the image should be mapped to volumes.

ie
should I run docker with something like -v ./nextcloudLocal:/var/www/html/data

And regarding overwriting my concern was that the image would try to initialize a new instance and overwrite the data it found on volumes and/or S3

like always using official docs is good starting point:

Overview of the folders that can be mounted as volumes:
/var/www/html Main folder, needed for updating
/var/www/html/custom_apps installed / modified apps
/var/www/html/config local configuration
/var/www/html/data the actual data of your Nextcloud
/var/www/html/themes/<YOUR_CUSTOM_THEME> theming/branding

Thank you!