Auto-setup of Syncthing in local server cluster? Auto-add new servers? Auto-share default folder?

I would like to create a small local server cluster with Docker Swarm, that automatically syncs a default folder with all local servers. Sub-folder may contain LetsEncrypt certs or uploaded files, that need to be available on all servers.

Is it possible to run Syncthing with a fixed configuration to

  1. automatically discover other local servers
  2. automatically accept other servers as devices
  3. automatically share default folder read/write with other servers
  4. without using the GUI and without any manual intervention

I built a whole API-using Docker Swarm setup for this use case, but it has so many moving parts that I don’t trust it enough to use it in production.

Therefore I would like to know (a little late :smile:) if this can be done by simple Syncthing configuration.

I searched the Internet and Forum, but only ChatGPT had good answers, though sadly it seems they were just hallucinations:

Environment variables:

STDISCOVER: Set this variable to "local" to enable local network discovery for Syncthing.

Set the environment variable STAUTOACCEPTFOLDERS=<folder_id> to specify the folder ID(s) that should be auto-accepted for new devices.

So is this use case possible spinning up Syncthing instances with environment variables or a fixed config file?

Nope. And yeah, that AI stuff is just fantasy. Doing it via the API is the way.

Thanks for your response. Could you elaborate what is not possible?

At least the device discovery within local network should work, as there is the Local Discovery Protocol, or am I misunderstand the purpose?

For the missing pieces, is there any chance to create feature requests that might be implemented?

Syncthing does number one out of the box, for servers that are already configured, that’s what we call local discovery. Number two is “nope”, you need to add devices via the API. Number three can work if the devices are configured to auto accept folders, but since you’re any way adding them via the API you might as well add the folder element there as well.

The main missing piece seems to be automaticlly adding any device in the vicinity, which I give roughly 0% odds of survival as a feature request.

You can retrieve the local discovery results (even for unknown / not yet added devices) over the API though. The GUI uses it to suggest local device IDs when adding a new one to the configuration. See GET /rest/system/discovery — Syncthing documentation.

Thanks. In my inline script I pull the servers via docker.sock.

What I really want to achieve is the servers in the network to discover and add each other by themself, without needing an additional process to call the API.

Ideally I would like to start similar configured SyncThing containers in Docker Swarm (something like STLOCALDISCOVERY=true, STAUTOADDDEVICES=true, STDEFAULTFOLDER=/var/syncthing, STAUTOSHAREDEFAULT=true) and they would automatically build a SyncThing cluster with a single shared folder. When I add another server, it will be automatically included. Without using the API.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.