Syncthing P2P Sync
Syncthing for peer-to-peer file synchronization.
Overview
Syncthing is an open-source continuous file synchronization program that enables real-time, peer-to-peer file sharing between devices without relying on cloud services or centralized servers. Originally developed in 2013 as a privacy-focused alternative to commercial sync solutions, Syncthing uses end-to-end encryption and operates entirely on your own infrastructure, giving you complete control over your data while maintaining automatic synchronization across multiple devices.
This Docker stack combines Syncthing with NGINX to create a robust file synchronization platform where Syncthing handles the peer-to-peer sync operations and device communication while NGINX provides HTTP acceleration and can serve as a reverse proxy for the web interface. The combination addresses common deployment challenges like port management, SSL termination, and scaling across multiple Syncthing instances in larger environments.
This setup is ideal for privacy-conscious users, small teams, and organizations that need reliable file synchronization without monthly cloud storage fees or data sovereignty concerns. Home lab enthusiasts will appreciate the self-hosted nature, while small businesses benefit from unlimited storage capacity and no per-user licensing costs compared to commercial alternatives like Dropbox or Google Drive.
Key Features
- Peer-to-peer synchronization with no central server or cloud dependency
- End-to-end AES encryption with TLS 1.3 for data in transit
- Real-time conflict detection and resolution with versioning support
- Selective folder sharing with granular device permissions
- Cross-platform device discovery via local broadcast and global discovery
- Web-based GUI for device management and folder configuration
- Bandwidth limiting and scheduling for sync operations
- NGINX reverse proxy support for SSL termination and caching
Common Use Cases
- 1Personal file synchronization between home computers, laptops, and mobile devices
- 2Small team document sharing without cloud storage subscriptions
- 3Photographer workflow for syncing RAW files between editing workstations
- 4Developer environment synchronization across multiple development machines
- 5Remote office backup strategy with automatic file replication
- 6Home media server synchronization for music and video libraries
- 7Secure document sharing for legal or healthcare practices requiring HIPAA compliance
Prerequisites
- Minimum 256MB RAM for Syncthing operations and file monitoring
- Available ports 8384 (web UI), 22000 (sync), and 21027 (discovery)
- Persistent storage location for synchronized files (minimum 1GB recommended)
- Network connectivity between devices for peer-to-peer communication
- Basic understanding of device IDs and folder sharing concepts
- Firewall configuration allowing Syncthing discovery and sync ports
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 restart: unless-stopped6 hostname: syncthing7 ports: 8 - "${SYNCTHING_PORT:-8384}:8384"9 - "22000:22000/tcp"10 - "22000:22000/udp"11 - "21027:21027/udp"12 environment: 13 - PUID=100014 - PGID=100015 volumes: 16 - syncthing_config:/var/syncthing/config17 - ${SYNC_PATH:-./sync}:/var/syncthing/data1819 nginx: 20 image: nginx:alpine21 container_name: syncthing-nginx22 restart: unless-stopped23 ports: 24 - "${NGINX_PORT:-80}:80"25 volumes: 26 - ./nginx.conf:/etc/nginx/nginx.conf:ro2728volumes: 29 syncthing_config: .env Template
.env
1# Syncthing2SYNCTHING_PORT=83843SYNC_PATH=./sync4NGINX_PORT=80Usage Notes
- 1Syncthing at http://localhost:8384
- 2Get device ID for pairing
- 3No cloud required
- 4End-to-end encrypted
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
syncthing
syncthing:
image: syncthing/syncthing:latest
container_name: syncthing
restart: unless-stopped
hostname: syncthing
ports:
- ${SYNCTHING_PORT:-8384}:8384
- 22000:22000/tcp
- 22000:22000/udp
- 21027:21027/udp
environment:
- PUID=1000
- PGID=1000
volumes:
- syncthing_config:/var/syncthing/config
- ${SYNC_PATH:-./sync}:/var/syncthing/data
nginx
nginx:
image: nginx:alpine
container_name: syncthing-nginx
restart: unless-stopped
ports:
- ${NGINX_PORT:-80}:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 syncthing:5 image: syncthing/syncthing:latest6 container_name: syncthing7 restart: unless-stopped8 hostname: syncthing9 ports:10 - "${SYNCTHING_PORT:-8384}:8384"11 - "22000:22000/tcp"12 - "22000:22000/udp"13 - "21027:21027/udp"14 environment:15 - PUID=100016 - PGID=100017 volumes:18 - syncthing_config:/var/syncthing/config19 - ${SYNC_PATH:-./sync}:/var/syncthing/data2021 nginx:22 image: nginx:alpine23 container_name: syncthing-nginx24 restart: unless-stopped25 ports:26 - "${NGINX_PORT:-80}:80"27 volumes:28 - ./nginx.conf:/etc/nginx/nginx.conf:ro2930volumes:31 syncthing_config:32EOF3334# 2. Create the .env file35cat > .env << 'EOF'36# Syncthing37SYNCTHING_PORT=838438SYNC_PATH=./sync39NGINX_PORT=8040EOF4142# 3. Start the services43docker compose up -d4445# 4. View logs46docker 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-sync-stack/run | bashTroubleshooting
- Devices not discovering each other: Check firewall rules for ports 21027/udp and 22000, or manually add device IDs
- Sync conflicts appearing frequently: Enable file versioning in folder settings and check for clock synchronization between devices
- High CPU usage during initial sync: Adjust scan intervals in advanced folder settings and enable bandwidth limiting
- Web UI showing 'CSRF Error': Clear browser cache and cookies, or access via localhost instead of external IP
- Files not syncing after changes: Verify folder is not paused, check ignore patterns, and ensure sufficient disk space on target devices
- NGINX proxy returning 502 errors: Confirm Syncthing container is healthy and listening on port 8384 before NGINX starts
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
Ad Space
Shortcuts: C CopyF FavoriteD Download