Setup RustDesk Server on Docker: The Ultimate Private Remote Desktop for Your HomeLab

HomeLab tutorial - IT technology blog
HomeLab tutorial - IT technology blog

Why Proprietary Tools Just Don’t Cut It Anymore

Juggling headless servers, VMs, and workstations is part of the HomeLab life. For years, we relied on TeamViewer or AnyDesk. They worked—until they didn’t. Most of us have been hit with that “Commercial use detected” popup right when we needed to fix something critical. It’s a frustrating roadblock that usually ends in a $20-a-month subscription request for features that used to be free.

Cost isn’t the only problem. Privacy matters too. When you use public tools, every mouse movement and keystroke passes through a corporate server. If their relay in another country is overloaded, you get hit with lag that makes troubleshooting impossible. For a self-hosted enthusiast, relying on the cloud to manage a server sitting three feet away feels like bad architecture.

Why Public Relays Often Fail

To fix this, we have to look at the plumbing. Most remote tools use an ID Server and a Relay Server. The ID Server acts like a phonebook, helping your laptop find your server. If a direct peer-to-peer (P2P) connection fails because of a stubborn firewall, your traffic tunnels through a Relay Server.

Public relays are often crowded. When your cursor takes two seconds to respond, it’s usually because your data is taking a scenic tour across the continent. Hosting your own server brings that “phonebook” and “tunnel” inside your own network. You get total autonomy. More importantly, you stop being at the mercy of a company’s changing terms of service.

The Field: Why RustDesk Wins

MeshCentral and Apache Guacamole are solid options, but they can be heavy. MeshCentral is powerful but feels like a cockpit with too many buttons. Guacamole is great for browsers but lacks the native “snappiness” of a dedicated app for file transfers. RustDesk hits the sweet spot. It is written in Rust, making it extremely light—it typically uses less than 50MB of RAM. You get native apps for Windows, Linux, macOS, and mobile, giving you a “pro” experience for free.

Setting Up Your Server in 5 Minutes

Docker is the fastest way to get this running. It keeps the installation isolated and makes updates a single command away. I’ve used this setup to manage multiple servers across different cities, and it remains rock-solid even on shaky 4G mobile connections.

Prerequisites

  • A server with Docker and Docker Compose installed.
  • Basic terminal skills.
  • Ports 21115-21119 (TCP) and 21116 (UDP) open on your firewall.

Step 1: Create the Project Directory

Let’s keep things organized by creating a dedicated folder.

mkdir -p ~/rustdesk-server && cd ~/rustdesk-server

Step 2: Define the Docker Compose Configuration

We need two containers: hbbs (the ID server) and hbbr (the Relay server). Create a docker-compose.yml file:

version: '3'

services:
  hbbs:
    container_name: hbbs
    image: rustdesk/rustdesk-server:latest
    command: hbbs -r your_server_ip_or_domain
    volumes:
      - ./data:/root
    network_mode: host
    depends_on:
      - hbbr
    restart: unless-stopped

  hbbr:
    container_name: hbbr
    image: rustdesk/rustdesk-server:latest
    command: hbbr
    volumes:
      - ./data:/root
    network_mode: host
    restart: unless-stopped

Pro Tip: Replace your_server_ip_or_domain with your public IP or DDNS. Using network_mode: host is the easiest way to handle the wide range of ports RustDesk requires without NAT headaches.

Step 3: Launch the Services

Fire up the containers in the background:

docker compose up -d

Your server generates a security key automatically to prevent strangers from hijacking your relay. Grab it with this command:

cat ./data/id_ed25519.pub

Configuring Your Clients

Now, tell the RustDesk client to stop using the public grid and start using your private server.

  1. Open the RustDesk client.
  2. Click the menu dots and select Settings > Network.
  3. Click Unlock network settings.
  4. In the ID Server field, enter your server’s IP address.
  5. Paste the key you just generated into the Key field.

Once you see “Ready” at the bottom, you are officially self-hosted.

Performance and Security Reality Check

The performance boost is massive. I’ve seen latency drop from 150ms on public relays to under 10ms on a local server. It makes the remote session feel like you’re sitting right in front of the machine.

Security is also tighter. The mandatory public key ensures only you can use your bandwidth. For maximum security, you can skip opening ports to the internet and use a VPN like Tailscale or WireGuard instead. This hides your entire remote desktop infrastructure from the public web while still giving you access from anywhere in the world.

This setup is now the backbone of my HomeLab management. It’s lightweight, respects my data, and it doesn’t nag me for money every time I need to fix a server at 2 AM.

Share: