How to Self-Host Syncthing with Docker Compose
What is Syncthing?
Syncthing is a continuous file synchronization tool that syncs files directly between your devices — no cloud server involved. It’s like Dropbox without the cloud. Files are encrypted in transit, never touch a third-party server, and sync happens automatically whenever devices are online together. It’s one of the simplest and most reliable self-hosted tools available.
Prerequisites
- Docker and Docker Compose installed (Docker Compose basics)
- At least two devices you want to sync between
Docker Compose Configuration
# docker-compose.yml for Syncthing# Tested with Syncthing 1.27+
services: syncthing: container_name: syncthing image: syncthing/syncthing:latest ports: - "8384:8384" # Web UI - "22000:22000/tcp" # File transfer - "22000:22000/udp" # QUIC file transfer - "21027:21027/udp" # Discovery volumes: - ./config:/var/syncthing/config - /path/to/sync/folder:/var/syncthing/data environment: - PUID=1000 - PGID=1000 restart: unless-stoppedStep-by-Step Setup
-
Create a directory:
Terminal window mkdir ~/syncthing && cd ~/syncthing -
Create the
docker-compose.yml— update/path/to/sync/folderto the directory you want to sync. -
Start the container:
Terminal window docker compose up -d -
Access the web UI at
http://your-server-ip:8384 -
Install Syncthing on your other device — download from syncthing.net or install via Docker there too.
-
Add devices: In the web UI, click “Add Remote Device” and enter the Device ID from your other Syncthing instance (shown under Actions → Show ID).
-
Share a folder: Click “Add Folder,” set the path, and select which devices to share it with.
-
Accept on the other device — the other instance will show a notification to accept the folder share.
Configuration Tips
- File versioning: Enable “Staggered File Versioning” on shared folders to keep old versions of changed files. Saved me many times.
- Ignore patterns: Create a
.stignorefile in any shared folder to exclude files (likenode_modules,.DS_Store, temp files). - Selective sync: You can choose different folders to sync with different devices. Your phone doesn’t need your entire file collection.
- Android app: Syncthing has an excellent Android app that can auto-sync camera photos to your server.
- Relay servers: If two devices can’t connect directly, Syncthing uses encrypted relay servers. This is automatic but adds latency.
Backup & Migration
- Backup: The
configfolder contains your device keys and sync configuration. Back it up — if you lose your keys, you’ll need to re-pair all devices. - Migration: Copy the
configfolder to a new installation. Update folder paths if they’ve changed.
Troubleshooting
- Devices not connecting: Ensure port 22000 isn’t blocked by firewalls. Syncthing will fall back to relay servers if direct connections fail, but it’s slower.
- Sync conflicts: Syncthing creates conflict files (
.sync-conflict-*) when both sides change the same file. Review and resolve manually. - Slow sync: Initial sync of large directories takes time. Subsequent syncs are fast (only changed blocks are transferred).
Alternatives
Nextcloud provides file sync plus a full cloud platform (calendar, contacts, apps). Seafile is another server-based option optimized for fast sync. See our Nextcloud vs Syncthing comparison or the full Best Self-Hosted File Sync roundup.
Verdict
Syncthing is the gold standard for peer-to-peer file sync. No server, no accounts, no cloud — just direct, encrypted sync between your devices. If you only need to keep files in sync (no web access, no sharing links), Syncthing is simpler and more reliable than any server-based solution.