How to Set Up Your Own RustDesk Server with Docker Compose

Looking for a secure, private, and open-source alternative to TeamViewer?
RustDesk is a fantastic choice — and by hosting it yourself in Docker Compose, you gain full control over your remote access solution.

This guide will walk you through setting up a RustDesk server from scratch, configuring it for secure access, and connecting your clients.


Why Host RustDesk Yourself?

Running RustDesk on your own server means:

  • Full privacy — no third-party relays.
  • Better performance with a direct connection to your network.
  • Custom security — control passwords, keys, and allowed clients.
  • Cost savings — no subscription fees.

Prerequisites

Before you begin, make sure you have:

  • Docker and Docker Compose installed
  • A public IP address or domain name
  • Opened ports 21115-21119 (TCP/UDP) in your firewall

Step 1 – Install Docker and Docker Compose

On a fresh server, install and enable Docker:

sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io docker-compose
sudo systemctl enable --now docker

Step 2 – Create a Working Directory

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

Step 3 – Create the docker-compose.yml

sudo vim docker-compose.yml
version: '3'

services:
  hbbs:
    image: ${RUSTDESK_IMAGE}
    container_name: rustdesk-hbbs
    restart: unless-stopped
    network_mode: "host"
    environment:
      - TZ=${TZ}
      - RUSTDESK_RELAY_PASSWORD=${RUSTDESK_RELAY_PASSWORD}
      - RUSTDESK_ALLOWED_IDS=${RUSTDESK_ALLOWED_IDS}
      - ALWAYS_USE_RELAY=Y
      - RUSTDESK_SSH_KEY=/root/.ssh/authorized_keys
    volumes:
      - rustdesk-data:/data
      - ./data:/root
    depends_on:
      - hbbr
    command: ["hbbs", "-r", "127.0.0.1:21117"]

  hbbr:
    image: ${RUSTDESK_IMAGE}
    container_name: rustdesk-hbbr
    restart: unless-stopped
    network_mode: "host"
    environment:
      - TZ=${TZ}
    volumes:
      - rustdesk-data:/data
      - ./data:/root
    command: ["hbbr"]

volumes:
  rustdesk-data:

Step 4 – Configure Environment Variables

Create a .env file to store your configuration:

touch .env && vim .env
RUSTDESK_IMAGE=rustdesk/rustdesk-server

RUSTDESK_PORT1=21115
RUSTDESK_PORT2=21116
RUSTDESK_PORT3=21117
RUSTDESK_PORT4=21118
RUSTDESK_PORT5=21119
RUSTDESK_UDP_PORT=21116

RUSTDESK_RELAY_PASSWORD="your-strong-password"
RUSTDESK_ALLOWED_IDS=
RUSTDESK_SSH_KEY=/root/.ssh/authorized_keys

TZ=Europe/Kiev

💡 Tip: Use a strong, unique password for RUSTDESK_RELAY_PASSWORD to prevent unauthorized access.


Step 5 – Launch the Server

docker-compose up -d

Verify that containers are running:

docker ps

Step 6 – Connect a RustDesk Client

  1. Download RustDesk from the official website.
  2. Open Settings → Server.
  3. Enter your server’s IP or domain in ID Server.
  4. Input the RUSTDESK_RELAY_PASSWORD from your .env file.
  5. If using SSH authentication, add your public key to ~/.ssh/authorized_keys on the server.

Step 7 – Manage the Server

  • Stop server:
docker-compose down
  • Restart server:
docker-compose restart
  • View logs:
docker-compose logs -f

Optional – Secure with HTTPS

For encrypted connections, set up a reverse proxy with Nginx or Traefik in front of your RustDesk server.


Final Thoughts

By hosting RustDesk in Docker Compose, you get a fast, secure, and private remote access system without relying on external services.

🚀 Next step: Deploy it today and enjoy complete control over your remote desktop connections.

🚀 Explore more guides on our blog 👉 blog.1it.pro
📧 Contact us: admin@1it.pro for expert IT guidance.
🌐 Explore more: Visit 1it.pro for top-tier IT solutions.

UA EN RU

Зв'язатися з нами

Telegram Email