Skip to content

Setting Up Syncthing with Docker Compose

Introduction to Syncthing

Syncthing is an open-source continuous file synchronization program. It synchronizes files between two or more computers in real time, safely and efficiently.

Docker Compose Configuration for Syncthing

This Docker Compose setup deploys Syncthing in a Docker container, ensuring a secure and isolated environment for file synchronization.

Docker Compose File (docker-compose.yml)

version: "2.1"
services:
  syncthing:
    image: lscr.io/linuxserver/syncthing:latest
    container_name: syncthing
    hostname: syncthing #optional
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /path/to/appdata/config:/config
      - /path/to/data1:/data1
      - /path/to/data2:/data2
    ports:
      - 8384:8384
      - 22000:22000/tcp
      - 22000:22000/udp
      - 21027:21027/udp
    restart: unless-stopped

Key Components of the Configuration

Environment Variables

  • PUID=1000 and PGID=1000: Sets user and group IDs for file permissions.
  • TZ=Etc/UTC: Sets the container's timezone.

Volumes

  • /path/to/appdata/config:/config: Maps the local config directory to the container's config directory.
  • /path/to/data1:/data1: Maps the first local data directory to the container.
  • /path/to/data2:/data2: Maps the second local data directory to the container.

Ports

  • 8384:8384: Web GUI.
  • 22000:22000/tcp and 22000:22000/udp: Device communication.
  • 21027:21027/udp: Local network discovery.

Restart Policy

  • unless-stopped: Ensures the container restarts automatically unless explicitly stopped.

Replace placeholder paths

Replace /path/to/appdata/config, /path/to/data1, and /path/to/data2 with absolute paths on your host — the directories you actually want to sync.

Deploying Syncthing

docker compose up -d

Once running, access the Syncthing web UI at http://<your-server-ip>:8384.

Set a GUI password immediately

Syncthing's web UI has no authentication by default. Anyone on your network can access and control it. Go to Settings → GUI and set a username and password before adding any devices.

Connecting Devices

To sync between devices, open the Syncthing UI on both, copy the Device ID from one, and add it as a remote device on the other. Both devices must accept the connection before syncing begins.


If there is an issue with this guide or you wish to suggest changes, please raise an issue on GitHub.