docker.recipes

RustDesk Server

beginner

Self-hosted remote desktop infrastructure, TeamViewer/AnyDesk alternative.

Overview

RustDesk is an open-source remote desktop solution that provides a self-hosted alternative to proprietary services like TeamViewer and AnyDesk. Originally developed as a cross-platform remote desktop client, RustDesk includes server components that enable organizations to maintain complete control over their remote access infrastructure, eliminating reliance on third-party services and ensuring sensitive data never leaves their network perimeter. The server implementation consists of two primary components: hbbs (ID/rendezvous server) and hbbr (relay server), which work in tandem to facilitate secure peer-to-peer connections. The hbbs component functions as the central coordination hub, managing client registration, authentication, and initial connection brokering between remote desktop sessions. Meanwhile, hbbr serves as the relay server that handles NAT traversal and maintains connections when direct peer-to-peer communication isn't possible due to network configurations or firewall restrictions. This dual-server architecture ensures reliable connectivity across diverse network topologies while maintaining the performance benefits of direct connections whenever feasible. This stack is particularly valuable for organizations requiring compliance with data residency regulations, companies with stringent security policies that prohibit external remote access services, and technical teams seeking customizable remote desktop solutions. System administrators managing distributed teams, MSPs providing remote support services, and privacy-conscious users who prefer self-hosted alternatives will find this configuration essential for maintaining secure, auditable remote access capabilities without subscription costs or external dependencies.

Key Features

  • Ed25519 cryptographic key-based authentication for tamper-resistant client verification
  • Mandatory encryption enforcement preventing unencrypted remote desktop sessions
  • Automatic NAT traversal through dedicated relay server for complex network topologies
  • Cross-platform client support including Windows, macOS, Linux, iOS, and Android
  • Direct peer-to-peer connections bypassing relay when network conditions permit
  • Centralized connection logging and session management through hbbs coordination
  • Custom server configuration allowing white-label deployment for service providers
  • UDP and TCP dual-protocol support optimizing performance based on network conditions

Common Use Cases

  • 1Enterprise IT departments replacing TeamViewer subscriptions with self-hosted remote support
  • 2Managed service providers offering branded remote desktop access to clients
  • 3Educational institutions providing secure remote lab access to students and faculty
  • 4Healthcare organizations ensuring HIPAA-compliant remote workstation access
  • 5Financial services maintaining SOX compliance while enabling remote work capabilities
  • 6Government agencies requiring air-gapped remote desktop infrastructure
  • 7Software development teams accessing development servers and testing environments securely

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2 for container orchestration support
  • Minimum 512MB RAM allocation for both hbbs and hbbr server processes
  • Available ports 21115-21119 for client connections and inter-service communication
  • Static IP address or dynamic DNS configuration for client endpoint discovery
  • Firewall rules permitting inbound UDP/TCP traffic on designated RustDesk ports
  • SSL certificate management strategy for production deployments with custom domains

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 hbbs:
3 image: rustdesk/rustdesk-server:latest
4 container_name: rustdesk-hbbs
5 command: hbbs
6 environment:
7 - ENCRYPTED_ONLY=1
8 volumes:
9 - rustdesk-data:/root
10 ports:
11 - "21115:21115"
12 - "21116:21116"
13 - "21116:21116/udp"
14 - "21118:21118"
15 networks:
16 - rustdesk-network
17 restart: unless-stopped
18
19 hbbr:
20 image: rustdesk/rustdesk-server:latest
21 container_name: rustdesk-hbbr
22 command: hbbr
23 volumes:
24 - rustdesk-data:/root
25 ports:
26 - "21117:21117"
27 - "21119:21119"
28 networks:
29 - rustdesk-network
30 restart: unless-stopped
31
32volumes:
33 rustdesk-data:
34
35networks:
36 rustdesk-network:
37 driver: bridge

.env Template

.env
1# RustDesk Server
2# Public key will be generated in rustdesk-data volume
3# Configure clients with your server IP and public key

Usage Notes

  1. 1ID server (hbbs) handles connections
  2. 2Relay server (hbbr) for NAT traversal
  3. 3Get public key from data/id_ed25519.pub
  4. 4Configure clients with server IP + key
  5. 5Encrypted connections only

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

hbbs
hbbs:
  image: rustdesk/rustdesk-server:latest
  container_name: rustdesk-hbbs
  command: hbbs
  environment:
    - ENCRYPTED_ONLY=1
  volumes:
    - rustdesk-data:/root
  ports:
    - "21115:21115"
    - "21116:21116"
    - 21116:21116/udp
    - "21118:21118"
  networks:
    - rustdesk-network
  restart: unless-stopped
hbbr
hbbr:
  image: rustdesk/rustdesk-server:latest
  container_name: rustdesk-hbbr
  command: hbbr
  volumes:
    - rustdesk-data:/root
  ports:
    - "21117:21117"
    - "21119:21119"
  networks:
    - rustdesk-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 hbbs:
5 image: rustdesk/rustdesk-server:latest
6 container_name: rustdesk-hbbs
7 command: hbbs
8 environment:
9 - ENCRYPTED_ONLY=1
10 volumes:
11 - rustdesk-data:/root
12 ports:
13 - "21115:21115"
14 - "21116:21116"
15 - "21116:21116/udp"
16 - "21118:21118"
17 networks:
18 - rustdesk-network
19 restart: unless-stopped
20
21 hbbr:
22 image: rustdesk/rustdesk-server:latest
23 container_name: rustdesk-hbbr
24 command: hbbr
25 volumes:
26 - rustdesk-data:/root
27 ports:
28 - "21117:21117"
29 - "21119:21119"
30 networks:
31 - rustdesk-network
32 restart: unless-stopped
33
34volumes:
35 rustdesk-data:
36
37networks:
38 rustdesk-network:
39 driver: bridge
40EOF
41
42# 2. Create the .env file
43cat > .env << 'EOF'
44# RustDesk Server
45# Public key will be generated in rustdesk-data volume
46# Configure clients with your server IP and public key
47EOF
48
49# 3. Start the services
50docker compose up -d
51
52# 4. View logs
53docker 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/rustdesk-server/run | bash

Troubleshooting

  • Clients cannot discover server: Verify ports 21115-21116 are accessible and DNS resolution points to correct server IP address
  • Connection established but screen sharing fails: Check that port 21117 (relay server) is properly forwarded and hbbr container is running
  • Authentication failures with correct key: Ensure ENCRYPTED_ONLY=1 is set and clients are using the public key from id_ed25519.pub file
  • High CPU usage on relay server: Monitor concurrent connections and consider scaling hbbr instances for environments exceeding 50 simultaneous sessions
  • Intermittent disconnections during sessions: Verify UDP port 21116 is not blocked by ISP or corporate firewall policies
  • Unable to retrieve public key for client configuration: Check that rustdesk-data volume is properly mounted and containers have write access to /root directory

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