docker.recipes

Syncthing P2P Sync

beginner

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:latest
4 container_name: syncthing
5 restart: unless-stopped
6 hostname: syncthing
7 ports:
8 - "${SYNCTHING_PORT:-8384}:8384"
9 - "22000:22000/tcp"
10 - "22000:22000/udp"
11 - "21027:21027/udp"
12 environment:
13 - PUID=1000
14 - PGID=1000
15 volumes:
16 - syncthing_config:/var/syncthing/config
17 - ${SYNC_PATH:-./sync}:/var/syncthing/data
18
19 nginx:
20 image: nginx:alpine
21 container_name: syncthing-nginx
22 restart: unless-stopped
23 ports:
24 - "${NGINX_PORT:-80}:80"
25 volumes:
26 - ./nginx.conf:/etc/nginx/nginx.conf:ro
27
28volumes:
29 syncthing_config:

.env Template

.env
1# Syncthing
2SYNCTHING_PORT=8384
3SYNC_PATH=./sync
4NGINX_PORT=80

Usage Notes

  1. 1Syncthing at http://localhost:8384
  2. 2Get device ID for pairing
  3. 3No cloud required
  4. 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 file
2cat > docker-compose.yml << 'EOF'
3services:
4 syncthing:
5 image: syncthing/syncthing:latest
6 container_name: syncthing
7 restart: unless-stopped
8 hostname: syncthing
9 ports:
10 - "${SYNCTHING_PORT:-8384}:8384"
11 - "22000:22000/tcp"
12 - "22000:22000/udp"
13 - "21027:21027/udp"
14 environment:
15 - PUID=1000
16 - PGID=1000
17 volumes:
18 - syncthing_config:/var/syncthing/config
19 - ${SYNC_PATH:-./sync}:/var/syncthing/data
20
21 nginx:
22 image: nginx:alpine
23 container_name: syncthing-nginx
24 restart: unless-stopped
25 ports:
26 - "${NGINX_PORT:-80}:80"
27 volumes:
28 - ./nginx.conf:/etc/nginx/nginx.conf:ro
29
30volumes:
31 syncthing_config:
32EOF
33
34# 2. Create the .env file
35cat > .env << 'EOF'
36# Syncthing
37SYNCTHING_PORT=8384
38SYNC_PATH=./sync
39NGINX_PORT=80
40EOF
41
42# 3. Start the services
43docker compose up -d
44
45# 4. View logs
46docker compose logs -f

One-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 | bash

Troubleshooting

  • 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