Syncthing with Relay Server
Continuous file synchronization with self-hosted discovery and relay.
Overview
Syncthing is an open-source continuous file synchronization program that enables real-time, peer-to-peer file sharing across multiple devices without relying on cloud storage providers. Developed as a privacy-focused alternative to commercial sync services, Syncthing uses end-to-end encryption and operates entirely on a decentralized architecture, meaning your files never pass through third-party servers unless you explicitly configure relay servers for NAT traversal.
This stack combines the core Syncthing application with self-hosted discovery and relay infrastructure components. The syncthing-discovery service replaces the default public discovery servers, allowing devices to find each other within your private network or infrastructure. The syncthing-relay service provides NAT traversal capabilities for devices that cannot establish direct connections, such as mobile clients behind cellular networks or computers in restrictive corporate environments. Together, these components create a completely self-contained synchronization ecosystem that operates independently of Syncthing's public infrastructure.
This configuration is ideal for organizations requiring complete data sovereignty, homelab enthusiasts wanting full control over their sync infrastructure, or privacy-conscious users who prefer to minimize external dependencies. By hosting your own discovery and relay servers, you eliminate reliance on public Syncthing infrastructure while maintaining all the benefits of peer-to-peer synchronization, including conflict resolution, file versioning, and selective folder sharing across heterogeneous device ecosystems.
Key Features
- Peer-to-peer file synchronization with no central storage server required
- Self-hosted discovery server eliminates dependency on public Syncthing discovery infrastructure
- Private relay server enables NAT traversal for devices behind firewalls or restrictive networks
- End-to-end encryption ensures files remain encrypted during transit and relay
- File versioning with configurable retention policies and conflict resolution
- Selective synchronization with ignore patterns and folder-level permissions
- Web-based management interface for device pairing and folder configuration
- Cross-platform device support including mobile, desktop, and server platforms
Common Use Cases
- 1Enterprise environments requiring complete data sovereignty and no external service dependencies
- 2Remote development teams synchronizing code repositories and project files across distributed locations
- 3Creative agencies sharing large media files between offices without expensive cloud storage limits
- 4Homelab setups synchronizing configuration files and backups across multiple self-hosted services
- 5Privacy-focused organizations avoiding commercial cloud providers for sensitive document sharing
- 6Multi-site deployments needing reliable file sync between locations with varying network conditions
- 7Educational institutions providing student file synchronization without external data processing agreements
Prerequisites
- Minimum 512MB RAM allocated across all three containers (256MB for Syncthing, 128MB each for discovery and relay)
- Available ports 8384 (web UI), 8443 (discovery), 22000 (Syncthing protocol), 22067 (relay), 22070 (relay status), and 21027/UDP (local discovery)
- Understanding of Syncthing device IDs and folder sharing concepts for initial configuration
- Network firewall configuration allowing inbound connections on relay and discovery ports if serving external devices
- SSL/TLS certificate management knowledge if exposing discovery server over HTTPS to external networks
- Basic familiarity with Syncthing's ignore patterns and versioning configuration for folder management
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 syncthing: 3 image: syncthing/syncthing:latest4 container_name: syncthing5 environment: 6 - PUID=10007 - PGID=10008 volumes: 9 - syncthing-config:/var/syncthing/config10 - syncthing-data:/var/syncthing/data11 ports: 12 - "8384:8384"13 - "22000:22000/tcp"14 - "22000:22000/udp"15 - "21027:21027/udp"16 networks: 17 - syncthing-network18 restart: unless-stopped1920 discovery: 21 image: syncthing/discosrv:latest22 container_name: syncthing-discovery23 command: -listen=:844324 volumes: 25 - discovery-data:/var/discosrv26 ports: 27 - "8443:8443"28 networks: 29 - syncthing-network30 restart: unless-stopped3132 relay: 33 image: syncthing/relaysrv:latest34 container_name: syncthing-relay35 command: -listen=:22067 -status-srv=:2207036 volumes: 37 - relay-data:/var/relaysrv38 ports: 39 - "22067:22067"40 - "22070:22070"41 networks: 42 - syncthing-network43 restart: unless-stopped4445volumes: 46 syncthing-config: 47 syncthing-data: 48 discovery-data: 49 relay-data: 5051networks: 52 syncthing-network: 53 driver: bridge.env Template
.env
1# Syncthing with Relay2# Configure clients to use your discovery and relay serversUsage Notes
- 1Web UI at http://localhost:8384
- 2Discovery server at :8443
- 3Relay server at :22067
- 4Add folders and devices via UI
- 5End-to-end encrypted sync
Individual Services(3 services)
Copy individual services to mix and match with your existing compose files.
syncthing
syncthing:
image: syncthing/syncthing:latest
container_name: syncthing
environment:
- PUID=1000
- PGID=1000
volumes:
- syncthing-config:/var/syncthing/config
- syncthing-data:/var/syncthing/data
ports:
- "8384:8384"
- 22000:22000/tcp
- 22000:22000/udp
- 21027:21027/udp
networks:
- syncthing-network
restart: unless-stopped
discovery
discovery:
image: syncthing/discosrv:latest
container_name: syncthing-discovery
command: "-listen=:8443"
volumes:
- discovery-data:/var/discosrv
ports:
- "8443:8443"
networks:
- syncthing-network
restart: unless-stopped
relay
relay:
image: syncthing/relaysrv:latest
container_name: syncthing-relay
command: "-listen=:22067 -status-srv=:22070"
volumes:
- relay-data:/var/relaysrv
ports:
- "22067:22067"
- "22070:22070"
networks:
- syncthing-network
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 syncthing:5 image: syncthing/syncthing:latest6 container_name: syncthing7 environment:8 - PUID=10009 - PGID=100010 volumes:11 - syncthing-config:/var/syncthing/config12 - syncthing-data:/var/syncthing/data13 ports:14 - "8384:8384"15 - "22000:22000/tcp"16 - "22000:22000/udp"17 - "21027:21027/udp"18 networks:19 - syncthing-network20 restart: unless-stopped2122 discovery:23 image: syncthing/discosrv:latest24 container_name: syncthing-discovery25 command: -listen=:844326 volumes:27 - discovery-data:/var/discosrv28 ports:29 - "8443:8443"30 networks:31 - syncthing-network32 restart: unless-stopped3334 relay:35 image: syncthing/relaysrv:latest36 container_name: syncthing-relay37 command: -listen=:22067 -status-srv=:2207038 volumes:39 - relay-data:/var/relaysrv40 ports:41 - "22067:22067"42 - "22070:22070"43 networks:44 - syncthing-network45 restart: unless-stopped4647volumes:48 syncthing-config:49 syncthing-data:50 discovery-data:51 relay-data:5253networks:54 syncthing-network:55 driver: bridge56EOF5758# 2. Create the .env file59cat > .env << 'EOF'60# Syncthing with Relay61# Configure clients to use your discovery and relay servers62EOF6364# 3. Start the services65docker compose up -d6667# 4. View logs68docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/syncthing-relay/run | bashTroubleshooting
- Syncthing web UI shows 'connection refused': Check that port 8384 is properly mapped and not blocked by host firewall
- Devices cannot discover each other: Verify discovery server is accessible on port 8443 and configure custom discovery server URL in Syncthing settings
- Relay connection failures with 'no relay available': Ensure relay server port 22067 is accessible and properly configured in Syncthing relay settings
- High memory usage during large file sync: Increase container memory limits and consider adjusting Syncthing's database tuning parameters
- Files stuck in 'Syncing' state: Check for permission issues on mounted volumes and verify folder paths are correctly mapped between containers and host
- Discovery server fails to start with certificate errors: Generate proper SSL certificates or configure discovery server to run in HTTP-only mode for internal networks
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
syncthingsyncthing-discoverysyncthing-relay
Tags
#sync#file-sharing#syncthing#p2p#backup
Category
Storage & BackupAd Space
Shortcuts: C CopyF FavoriteD Download