Docker - Syncthing Container Setup
Syncthing is a great piece of software that lets you safely sychronize your files between different devices and operating systems. Here I describe my setup of the Syncthing docker container.
I run this Docker container on a Ubuntu VM that runs via [[ Proxmox VE ]]. I perform the following on the CLI.
Run the Docker pull command:
docker pull syncthing/syncthing
Within my home folder I have created a Docker folder where I create a subfolder for each container:
cd ~
mkdir -p docker/syncthing
cd docker/syncthing
Also create the following folders:
mkdir st-sync
mkdir data
I use the Nano text editor to create a shell script:
sudo nano syncthing_run.sh
With this shell script we are going to create the container.
Copy the following into syncthing_run.sh
:
IDu=$(id -u $(logname)) # Saves the logged in user id in the IDu variable
IDg=$(id -g $(logname)) # Saves the logged in user group in the IDg variable
docker run -d \
--name syncthing \
--hostname=syncthing-ubuntuvm \
--network=host \
-v $PWD/st-sync/:/var/syncthing/ \
-v $PWD/data/:/var/syncthing/data/ \
-v /mnt/fileserver/archive/:/var/syncthing/archive/ \
-e TZ="Europe/Amsterdam" \
-e PUID=$IDu \
-e PGID=$IDg \
--restart=unless-stopped \
syncthing/syncthing:latest
If necessary, adjust the following:
–hostname=syncthing-ubuntuvm
Since I have Syncthing running on multiple devices, the hostname will differ per device. In this case I chose my Ubuntu VM as an example. Replaceubuntuvm
with your own name
-v $PWD/data/:/var/syncthing/data/
This is an example of a folder you can sync. In this case the mapping allows us to select and sync the contents of the data folder within Syncthing. Adjust this to your own wishes
-v /mnt/fileserver/archive/:/var/syncthing/archive/
This is an example of a folder you can sync. In this case the mapping allows us to select and sync the contents of a folder from my fileserver which is mounted on the Docker host (Ubuntu). Adjust this to your own wishes
-e “TZ=Europe/Amsterdam”
Pick the right timezone
Exit Nano (CTRL-X) and save the changes.
Make sure port 8384
is available. Check this with netstat.
Now create the container:
sudo sh syncthing_run.sh
Check if the container is running properly.
Using Syncthing
Syncthing can now be accessed via the following URL:
http://<IP DOCKER HOST>:8384/
If you see a message about the inotify limits run the following on the Docker host:
echo "fs.inotify.max_user_watches=204800" | sudo tee -a /etc/sysctl.conf
sudo sh -c 'echo 204800 > /proc/sys/fs/inotify/max_user_watches'
In my case I had to run this on my Synology NAS where I had Syncthing running using the Docker application
Setup GUI
First I turned on authentication and the option to use HTTPS for the GUI:
-
Actions
>Settings
>GUI
>GUI Authentication User
: your syncthing user -
Actions
>Settings
>GUI
>GUI Authentication Password
: your syncthing password -
Actions
>Settings
>GUI
>Use HTTPS for GUI
: turnON
Now Syncthing can be accessed via the following URL (https instead of http!):
https://<IP DOCKER HOST>:8384/
Setup Connections
Within my local network I use Syncthing with a number of different devices that run on Linux, Windows and Android.
I disabled the following settings because I didn’t think it was necessary:
-
Actions
>Settings
>Connections
>Enable NAT traversal
: turnOFF
-
Actions
>Settings
>Connections
>Global Discovery
: turnOFF
-
Actions
>Settings
>Connections
>Enable Relaying
: turnOFF
(or do some research and make your own settings if desired)
Advanced Settings
Since sending crash reports is turned on by default without prompting I turned this off:
-
Actions
>Advanced
>Options
>Crash Reporting Enabled
: turnOFF
Sync
Now you can add folder(s) to sync by clicking on Add Folder
in the main screen. The Docker mappings can be selected by browsing under Folder Path
to /var/syncthing/
.
See also my notes about updating containers with Portainer or via the CLI. With Synology’s Docker Application, updating a container is also very easy.
Read other notes
Tags
Notes mentioning this note
- Obsidian - Installation and Syncing with Syncthing
I installed Obisidian on Windows (x2) and Android.
- NixOS - Server Configuration and Switch to Podman
For some time now I have been looking for an interesting lightweight linux distribution that could replace Ubuntu
Comments
No comments found for this note.
Join the discussion for this note on this ticket. Comments appear on this page instantly.