Skip to content

Syncthing container setup

Syncthing is an open-source self-hosted file synchronization solution. It allows you to sync files between different devices and operating systems. I use Syncthing to sync notes for example.

  1. Create the folders needed by the container
    Section titled “Create the folders needed by the container”

    Run the following commands inside your home folder:

    # Open your terminal application
    cd ~
    mkdir -p syncthing/var-syncthing
    mkdir -p syncthing/data
    cd syncthing
  2. Create the script needed to run the container
    Section titled “Create the script needed to run the container”

    Save the following script as syncthing_run.sh:

    syncthing_run.sh
    # To create this script use your text editor application, for example Nano
    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-vm1 \
    --net=host \
    -v $PWD/var-syncthing:/var/syncthing/ \
    -v $PWD/data:/var/syncthing/data/ \
    -v /mnt/fileserver/archive:/var/syncthing/archive/ \
    -e PUID=$IDu \
    -e PGID=$IDg \
    -e TZ="Europe/Amsterdam" \
    --restart=unless-stopped \
    syncthing/syncthing:latest
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Optional Replace docker with podman if needed
    • Required Replace hostname syncthing-vm1 with the name of your device when you have Syncthing running on multiple devices
    • Optional Replace --net=host with ports to pass through if you want to expose ports. Here is described how to check if ports are available. Make sure port 8384 is available
    • Required Replace $PWD/data with a local folder you want to sync. The folder /var/syncthing/data/ can then be selected to sync in the Syncthing settings
    • Optional Replace /mnt/fileserver/archive with a local folder you want to sync. The folder /var/syncthing/archive/ can then be selected to sync in the Syncthing settings. So it is possible to sync the contents of a folder from my fileserver which is mounted on the Docker host
    • Required Replace Europe/Amsterdam with your own timezone
  3. Run the following command:

    # Open your terminal application
    sudo sh syncthing_run.sh

    The image syncthing/syncthing is automatically pulled and the container is created.

  4. If needed you can check if the container is running properly.

    Now you can use Syncthing by opening a web browser and going to: http://localhost:8384. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

  5. To turn 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: turn ON

    Now you can use Syncthing by opening a web browser and going to: https://localhost:8384. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier. So use https instead of http.

    Within my local network Syncthing is running on Linux, Windows and Android. I disabled the following settings because I didn’t think it was necessary:

    • Actions > Settings > Connections > Enable NAT traversal: turn OFF
    • Actions > Settings > Connections > Global Discovery: turn OFF
    • Actions > Settings > Connections > Enable Relaying: turn OFF

    But just make your own choices here.

    Since sending crash reports is turned on by default without prompting I turned this off:

    • Actions > Advanced > Options > Crash Reporting Enabled: turn OFF

    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 Folder Path to /var/syncthing/.

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

     Copyright 2021-2026 Fiction Becomes Fact