diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..096f030 --- /dev/null +++ b/.env.example @@ -0,0 +1,74 @@ +# Windows Docker Container Environment Configuration +# Copy this file to .env and customize as needed + +# ==================== Windows Configuration ==================== +# Windows version to install +# Options: 11, 11l, 11e, 10, 10l, 10e, 8e, 7u, vu, xp, 2k, 2025, 2022, 2019, 2016, 2012, 2008, 2003 +VERSION=11 + +# Windows language +# Options: Arabic, Bulgarian, Chinese, Croatian, Czech, Danish, Dutch, English, +# Estonian, Finnish, French, German, Greek, Hebrew, Hungarian, Italian, +# Japanese, Korean, Latvian, Lithuanian, Norwegian, Polish, Portuguese, +# Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swedish, Thai, +# Turkish, Ukrainian +LANGUAGE=English + +# Region and keyboard layout (e.g., en-US, de-DE, fr-FR) +REGION=en-US +KEYBOARD=en-US + +# ==================== User Credentials ==================== +# Default username for Windows installation +USERNAME=Docker + +# Default password for Windows user +PASSWORD=admin + +# ==================== Hardware Configuration ==================== +# RAM size (e.g., 4G, 8G, 16G) +RAM_SIZE=4G + +# Number of CPU cores to allocate +CPU_CORES=2 + +# Primary disk size (e.g., 64G, 128G, 256G) +DISK_SIZE=64G + +# Additional disk configurations (optional) +# DISK2_SIZE=32G +# DISK3_SIZE=64G + +# ==================== Network Configuration ==================== +# Enable DHCP mode (Y/N) - Windows will get IP from router +DHCP=N + +# Arguments for QEMU (for advanced USB passthrough, etc.) +# ARGUMENTS=-device usb-host,vendorid=0x1234,productid=0x1234 + +# ==================== Port Mappings ==================== +# Web viewer port +WEB_PORT=8006 + +# RDP port (TCP) +RDP_PORT_TCP=3389 + +# RDP port (UDP) +RDP_PORT_UDP=3389 + +# ==================== Volume Mappings ==================== +# Storage location for Windows virtual machine +STORAGE_PATH=./windows + +# Shared folder location (appears as "Shared" folder in Windows) +# SHARED_PATH=./shared + +# OEM folder for custom installation scripts (install.bat) +# OEM_PATH=./oem + +# ==================== Installation Options ==================== +# Manual installation mode (Y/N) +MANUAL=N + +# Custom ISO URL or path +# VERSION=https://example.com/windows.iso diff --git a/.gitignore b/.gitignore index 8b13789..949652f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,8 @@ +# Environment files with sensitive data +.env +# Storage and data directories +windows/ +shared/ +oem/ +storage*/ diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 0000000..2ae09e1 --- /dev/null +++ b/SETUP.md @@ -0,0 +1,461 @@ +# Additional Setup and Configuration Guide + +This guide covers additional setup options including environment-based configuration, Docker Desktop installation, and RustDesk remote desktop setup. + +## Table of Contents + +- [Environment-Based Configuration](#environment-based-configuration) +- [Installing Docker Desktop on Windows](#installing-docker-desktop-on-windows) +- [RustDesk: Alternative Remote Desktop Solution](#rustdesk-alternative-remote-desktop-solution) +- [Comparison: RDP vs RustDesk](#comparison-rdp-vs-rustdesk) + +--- + +## Environment-Based Configuration + +### Using the .env File + +The repository now includes a `.env.example` file that provides a template for environment-based configuration. This allows you to manage hardware settings, credentials, and other configurations without modifying the `compose.yml` file directly. + +#### Setup Steps + +1. **Copy the example file:** + ```bash + cp .env.example .env + ``` + +2. **Edit the .env file:** + ```bash + nano .env # or use your preferred editor + ``` + +3. **Customize the settings:** + - **Windows Configuration:** Version, language, region, keyboard + - **User Credentials:** Username and password + - **Hardware:** RAM size, CPU cores, disk size + - **Network:** DHCP settings, port mappings + - **Storage:** Volume paths + +4. **Run Docker Compose:** + ```bash + docker compose up -d + ``` + +Docker Compose will automatically read the `.env` file and use the configured values. + +### Environment Variables Reference + +#### Windows Configuration +```bash +VERSION=11 # Windows version (11, 10, 2025, etc.) +LANGUAGE=English # Installation language +REGION=en-US # Region setting +KEYBOARD=en-US # Keyboard layout +``` + +#### User Credentials +```bash +USERNAME=Docker # Windows username +PASSWORD=admin # Windows password +``` + +#### Hardware Configuration +```bash +RAM_SIZE=4G # RAM allocation (4G, 8G, 16G, etc.) +CPU_CORES=2 # Number of CPU cores +DISK_SIZE=64G # Primary disk size +# Optional additional disks: +# DISK2_SIZE=32G +# DISK3_SIZE=64G +``` + +#### Network Configuration +```bash +DHCP=N # Enable/disable DHCP (Y/N) +WEB_PORT=8006 # Web viewer port +RDP_PORT_TCP=3389 # RDP TCP port +RDP_PORT_UDP=3389 # RDP UDP port +``` + +#### Volume Configuration +```bash +STORAGE_PATH=./windows # VM storage location +# Optional volumes: +# SHARED_PATH=./shared # Shared folder +# OEM_PATH=./oem # Custom installation scripts +``` + +### Benefits of .env Configuration + +- **Version Control:** Keep `.env` out of git (sensitive data) while sharing `.env.example` (template) +- **Easy Updates:** Change configuration without editing compose file +- **Multiple Environments:** Use different .env files for different setups +- **Security:** Keep credentials separate from code +- **Portability:** Share compose.yml safely without exposing settings + +--- + +## Installing Docker Desktop on Windows + +### Overview + +The `install-docker-desktop.ps1` script automates the installation of Docker Desktop on Windows with WSL2 backend support. + +### Prerequisites + +- Windows 10 version 2004 or higher (Build 19041+) or Windows 11 +- Administrator privileges +- At least 4GB of RAM available +- Virtualization enabled in BIOS + +### Installation Steps + +1. **Download the script** (if not already cloned): + ```powershell + # From this repository + Invoke-WebRequest -Uri "https://raw.githubusercontent.com/bbj4t/windows/main/install-docker-desktop.ps1" -OutFile "install-docker-desktop.ps1" + ``` + + > **Note:** If using a different fork or repository, replace `bbj4t/windows` with the appropriate repository path. + +2. **Open PowerShell as Administrator:** + - Right-click on PowerShell + - Select "Run as Administrator" + +3. **Run the installation script:** + ```powershell + .\install-docker-desktop.ps1 + ``` + +### Script Options + +```powershell +# Install specific version +.\install-docker-desktop.ps1 -Version "4.25.0" + +# Install without WSL2 (Hyper-V backend) +.\install-docker-desktop.ps1 -EnableWSL2:$false + +# Install without starting Docker Desktop +.\install-docker-desktop.ps1 -StartAfterInstall:$false + +# Skip prerequisite checks +.\install-docker-desktop.ps1 -SkipPrerequisites +``` + +### What the Script Does + +1. ✅ Checks Windows version compatibility +2. ✅ Enables WSL (Windows Subsystem for Linux) feature +3. ✅ Enables Virtual Machine Platform +4. ✅ Downloads Docker Desktop installer +5. ✅ Installs Docker Desktop with WSL2 backend +6. ✅ Starts Docker Desktop (optional) +7. ✅ Cleans up temporary files + +### Post-Installation + +After installation: + +1. Wait for Docker Desktop to initialize (1-2 minutes) +2. Verify installation: + ```powershell + docker --version + docker run hello-world + ``` +3. If prompted, restart your computer to complete WSL2 setup + +### Troubleshooting + +**Issue:** Docker fails to start after installation +- **Solution:** Restart your computer to complete WSL2 setup + +**Issue:** "Virtualization not enabled" error +- **Solution:** Enable Intel VT-x or AMD-V in BIOS settings + +**Issue:** WSL2 installation fails +- **Solution:** Run Windows Update and install all pending updates + +--- + +## RustDesk: Alternative Remote Desktop Solution + +### What is RustDesk? + +RustDesk is an open-source remote desktop software that serves as an alternative to traditional RDP, TeamViewer, and AnyDesk. It offers: + +- 🌐 **NAT Traversal:** Connect over the internet without port forwarding +- 🔒 **Custom Relay Servers:** Host your own relay for complete privacy +- 🆓 **Free and Open-Source:** No licensing costs or restrictions +- 🖥️ **Cross-Platform:** Windows, macOS, Linux, iOS, Android +- 🔐 **End-to-End Encryption:** Secure connections +- 🚀 **Low Latency:** Fast performance even over internet + +### Installing RustDesk Client + +#### Basic Installation + +1. **Open PowerShell as Administrator:** + ```powershell + # Download and run the installation script + .\install-rustdesk.ps1 + ``` + +2. **The script will:** + - Download the latest RustDesk version + - Install the client + - Install the RustDesk service (for unattended access) + - Start the application + +#### Custom Relay Server Installation + +To connect to your own RustDesk relay server: + +```powershell +.\install-rustdesk.ps1 -RelayServer "relay.yourdomain.com" -Key "your-public-key" +``` + +#### Advanced Options + +```powershell +# Install specific version +.\install-rustdesk.ps1 -Version "1.2.3" + +# Custom relay with API server +.\install-rustdesk.ps1 -RelayServer "relay.example.com" -ApiServer "api.example.com" -Key "your-key" + +# Install without service (portable mode) +.\install-rustdesk.ps1 -InstallService:$false + +# Install without auto-start +.\install-rustdesk.ps1 -StartAfterInstall:$false +``` + +### Setting Up Your Own RustDesk Relay Server + +If you want complete privacy and control, you can host your own RustDesk relay server: + +1. **Server Requirements:** + - Linux server (Ubuntu 20.04+ recommended) + - Public IP address + - Ports: 21115-21119 (TCP), 21116 (UDP) + +2. **Quick Server Setup:** + ```bash + # On your Linux server + wget https://raw.githubusercontent.com/rustdesk/rustdesk-server/master/install.sh + chmod +x install.sh + ./install.sh + ``` + +3. **Get Your Server Key:** + ```bash + cat /var/lib/rustdesk-server/id_ed25519.pub + ``` + +4. **Configure Clients:** + Use the installation script with your server details: + ```powershell + .\install-rustdesk.ps1 -RelayServer "your-server-ip" -Key "your-public-key" + ``` + +### Using RustDesk + +#### For Remote Access (Client): + +1. Launch RustDesk +2. Note your **RustDesk ID** (shown in main window) +3. Set a password for secure access (optional) +4. Share your ID with the person who needs to connect + +#### For Connecting to Another Computer: + +1. Launch RustDesk +2. Enter the remote **RustDesk ID** +3. Click "Connect" +4. Enter the password (if set) + +### RustDesk Configuration Files + +RustDesk stores its configuration in: +- **Windows:** `%APPDATA%\RustDesk\config\RustDesk2.toml` +- **Linux:** `~/.config/rustdesk/RustDesk2.toml` + +Example configuration: +```toml +relay-server = 'relay.yourdomain.com' +api-server = 'api.yourdomain.com' +key = 'your-public-key-here' +``` + +--- + +## Comparison: RDP vs RustDesk + +### When to Use RDP (Port 3389) + +✅ **Use RDP when:** +- On a local network (LAN) +- Connected via VPN +- Need Windows-native features +- Require Windows Server features +- Maximum performance is critical +- Network policy requires it + +### When to Use RustDesk + +✅ **Use RustDesk when:** +- Connecting over the internet (no VPN needed) +- Behind NAT/firewall without port forwarding +- Need cross-platform access (mobile, Linux, Mac) +- Want complete privacy with your own relay server +- RDP port (3389) is blocked or unsafe to expose +- Need file transfer and clipboard sync +- Want free, open-source solution + +### Feature Comparison + +| Feature | RDP | RustDesk | +|---------|-----|----------| +| **Internet Access** | Requires VPN or port forwarding | ✅ Built-in NAT traversal | +| **Port Forwarding** | Required | ❌ Not needed | +| **Cross-Platform** | Limited | ✅ Full support | +| **Mobile Apps** | Basic | ✅ Full-featured | +| **Custom Relay** | ❌ Not available | ✅ Self-hosted option | +| **Privacy** | Microsoft servers | ✅ Your own servers | +| **Cost** | License required | ✅ Free & Open-Source | +| **File Transfer** | Mapped drives | ✅ Built-in | +| **Setup Complexity** | Medium | Easy | +| **Performance** | Excellent (LAN) | Good (Internet) | + +### Recommended Setup + +**Best Practice:** Use both! + +1. **RDP (3389):** For local/VPN connections +2. **RustDesk:** For internet access and mobile + +Example compose.yml configuration: +```yaml +services: + windows: + image: dockurr/windows + ports: + - "8006:8006" # Web viewer + - "3389:3389" # RDP + environment: + VERSION: "11" + USERNAME: "Docker" + PASSWORD: "admin" +``` + +Then install RustDesk inside Windows VM using the installation script. + +--- + +## Security Considerations + +### For .env Files +- ✅ Never commit `.env` to git (use `.gitignore`) +- ✅ Use strong passwords +- ✅ Limit file permissions: `chmod 600 .env` +- ✅ Share `.env.example`, not `.env` + +### For RDP +- ✅ Use strong passwords (12+ characters) +- ✅ Enable Network Level Authentication (NLA) +- ✅ Use VPN when accessing over internet +- ⚠️ Don't expose port 3389 directly to internet + +### For RustDesk +- ✅ Set a strong password in RustDesk +- ✅ Use your own relay server for sensitive data +- ✅ Keep RustDesk updated +- ✅ Enable 2FA on your RustDesk account (if using public relay) + +--- + +## Troubleshooting + +### Docker Compose Issues + +**Issue:** Environment variables not loading +```bash +# Solution: Ensure .env is in the same directory as compose.yml +ls -la .env +docker compose config # Verify variables are loaded +``` + +**Issue:** Ports already in use +```bash +# Solution: Change ports in .env +WEB_PORT=8007 +RDP_PORT_TCP=3390 +``` + +### Docker Desktop Issues + +**Issue:** WSL2 not working after install +```powershell +# Solution: Update WSL kernel +wsl --update +wsl --set-default-version 2 +``` + +**Issue:** Docker service won't start +```powershell +# Solution: Restart Docker Desktop service +Restart-Service docker +``` + +### RustDesk Issues + +**Issue:** Cannot connect to custom relay +``` +# Solution: Check firewall and ports +- Verify ports 21115-21119 are open +- Check relay server is running +- Verify public key matches +``` + +**Issue:** RustDesk ID not showing +```powershell +# Solution: Restart RustDesk service +Restart-Service RustDesk +``` + +--- + +## Additional Resources + +### Documentation +- [Docker Documentation](https://docs.docker.com/) +- [Docker Compose Documentation](https://docs.docker.com/compose/) +- [RustDesk Documentation](https://rustdesk.com/docs/) +- [RustDesk Server Setup](https://github.com/rustdesk/rustdesk-server) + +### Community +- [Docker Community](https://www.docker.com/community/) +- [RustDesk Reddit](https://www.reddit.com/r/rustdesk/) +- [RustDesk Discord](https://discord.com/invite/nDceKgxnkV) + +### Security +- [Docker Security Best Practices](https://docs.docker.com/engine/security/) +- [RustDesk Security](https://rustdesk.com/docs/en/security/) + +--- + +## Contributing + +If you have suggestions or improvements for these setup scripts: + +1. Fork the repository +2. Create a feature branch +3. Make your changes +4. Submit a pull request + +--- + +## License + +This project follows the same license as the main repository. See [license.md](license.md) for details. diff --git a/compose.yml b/compose.yml index e5b6257..b00ed56 100644 --- a/compose.yml +++ b/compose.yml @@ -3,17 +3,30 @@ services: image: dockurr/windows container_name: windows environment: - VERSION: "11" + VERSION: "${VERSION:-11}" + LANGUAGE: "${LANGUAGE:-English}" + REGION: "${REGION:-en-US}" + KEYBOARD: "${KEYBOARD:-en-US}" + USERNAME: "${USERNAME:-Docker}" + PASSWORD: "${PASSWORD:-admin}" + RAM_SIZE: "${RAM_SIZE:-4G}" + CPU_CORES: "${CPU_CORES:-2}" + DISK_SIZE: "${DISK_SIZE:-64G}" + DHCP: "${DHCP:-N}" + MANUAL: "${MANUAL:-N}" + DISK2_SIZE: "${DISK2_SIZE}" + DISK3_SIZE: "${DISK3_SIZE}" + ARGUMENTS: "${ARGUMENTS}" devices: - /dev/kvm - /dev/net/tun cap_add: - NET_ADMIN ports: - - 8006:8006 - - 3389:3389/tcp - - 3389:3389/udp + - "${WEB_PORT:-8006}:8006" + - "${RDP_PORT_TCP:-3389}:3389/tcp" + - "${RDP_PORT_UDP:-3389}:3389/udp" volumes: - - ./windows:/storage + - "${STORAGE_PATH:-./windows}:/storage" restart: always stop_grace_period: 2m diff --git a/install-docker-desktop.ps1 b/install-docker-desktop.ps1 new file mode 100644 index 0000000..02c358a --- /dev/null +++ b/install-docker-desktop.ps1 @@ -0,0 +1,193 @@ +# Install Docker Desktop on Windows +# This script downloads and installs Docker Desktop with WSL2 backend +# Requires: Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 +# Run as Administrator + +param( + [string]$Version = "latest", + [switch]$EnableWSL2 = $true, + [switch]$StartAfterInstall = $true, + [switch]$SkipPrerequisites = $false +) + +# Function to check if running as administrator +function Test-Administrator { + $currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +# Function to write colored output +function Write-ColorOutput { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Color +} + +# Check if running as administrator +if (-not (Test-Administrator)) { + Write-ColorOutput "ERROR: This script must be run as Administrator!" "Red" + Write-ColorOutput "Please right-click PowerShell and select 'Run as Administrator'" "Yellow" + exit 1 +} + +Write-ColorOutput "`n========================================" "Cyan" +Write-ColorOutput "Docker Desktop Installation Script" "Cyan" +Write-ColorOutput "========================================`n" "Cyan" + +# Check Windows version +$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem +$buildNumber = [int]$osInfo.BuildNumber +$osVersion = $osInfo.Caption + +Write-ColorOutput "Detected OS: $osVersion (Build $buildNumber)" "Green" + +if ($buildNumber -lt 19041) { + Write-ColorOutput "ERROR: Docker Desktop requires Windows 10 Build 19041 or higher, or Windows 11" "Red" + Write-ColorOutput "Your build: $buildNumber" "Yellow" + exit 1 +} + +# Check and enable WSL2 if requested +if ($EnableWSL2 -and -not $SkipPrerequisites) { + Write-ColorOutput "`nChecking WSL2 prerequisites..." "Yellow" + + # Enable WSL feature + $wslFeature = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux + if ($wslFeature.State -ne "Enabled") { + Write-ColorOutput "Enabling WSL feature..." "Yellow" + Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart -WarningAction SilentlyContinue | Out-Null + } else { + Write-ColorOutput "WSL feature is already enabled" "Green" + } + + # Enable Virtual Machine Platform + $vmFeature = Get-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform + if ($vmFeature.State -ne "Enabled") { + Write-ColorOutput "Enabling Virtual Machine Platform..." "Yellow" + Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart -WarningAction SilentlyContinue | Out-Null + } else { + Write-ColorOutput "Virtual Machine Platform is already enabled" "Green" + } + + # Update WSL to version 2 + Write-ColorOutput "Updating WSL to version 2..." "Yellow" + try { + wsl --set-default-version 2 2>$null | Out-Null + Write-ColorOutput "WSL2 set as default" "Green" + } catch { + Write-ColorOutput "Note: WSL2 update may require a system restart" "Yellow" + } +} + +# Download Docker Desktop +$downloadPath = "$env:TEMP\DockerDesktopInstaller.exe" + +if ($Version -eq "latest") { + $downloadUrl = "https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe" + Write-ColorOutput "`nDownloading Docker Desktop (latest version)..." "Yellow" +} else { + # Note: Specific version URLs may vary. If download fails, use -Version "latest" or download manually + $downloadUrl = "https://desktop.docker.com/win/main/amd64/$Version/Docker%20Desktop%20Installer.exe" + Write-ColorOutput "`nDownloading Docker Desktop version $Version..." "Yellow" + Write-ColorOutput "Note: If download fails, version URL format may have changed" "Gray" +} + +try { + # Use Invoke-WebRequest for modern TLS support + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadPath -UseBasicParsing + $ProgressPreference = 'Continue' + Write-ColorOutput "Download completed successfully!" "Green" +} catch { + Write-ColorOutput "ERROR: Failed to download Docker Desktop" "Red" + Write-ColorOutput "Error: $_" "Red" + Write-ColorOutput "URL: $downloadUrl" "Yellow" + exit 1 +} + +# Verify download +if (-not (Test-Path $downloadPath)) { + Write-ColorOutput "ERROR: Downloaded file not found at $downloadPath" "Red" + exit 1 +} + +$fileSize = (Get-Item $downloadPath).Length / 1MB +Write-ColorOutput "Downloaded file size: $([math]::Round($fileSize, 2)) MB" "Green" + +# Install Docker Desktop +Write-ColorOutput "`nInstalling Docker Desktop..." "Yellow" +Write-ColorOutput "This may take several minutes. Please wait..." "Yellow" + +$installArgs = @( + "install", + "--quiet" +) + +if ($EnableWSL2) { + $installArgs += "--backend=wsl-2" +} + +try { + $process = Start-Process -FilePath $downloadPath -ArgumentList $installArgs -Wait -PassThru -NoNewWindow + + if ($process.ExitCode -eq 0) { + Write-ColorOutput "`nDocker Desktop installed successfully!" "Green" + } elseif ($process.ExitCode -eq 3010) { + Write-ColorOutput "`nDocker Desktop installed successfully (restart required)!" "Green" + } else { + Write-ColorOutput "`nERROR: Installation failed with exit code $($process.ExitCode)" "Red" + exit 1 + } +} catch { + Write-ColorOutput "ERROR: Failed to install Docker Desktop" "Red" + Write-ColorOutput "Error: $_" "Red" + exit 1 +} finally { + # Clean up installer + if (Test-Path $downloadPath) { + Remove-Item $downloadPath -Force + Write-ColorOutput "Cleaned up installer file" "Green" + } +} + +# Start Docker Desktop if requested +if ($StartAfterInstall) { + Write-ColorOutput "`nStarting Docker Desktop..." "Yellow" + try { + $dockerDesktopPath = "C:\Program Files\Docker\Docker\Docker Desktop.exe" + if (Test-Path $dockerDesktopPath) { + Start-Process $dockerDesktopPath + Write-ColorOutput "Docker Desktop started successfully!" "Green" + Write-ColorOutput "Please wait for Docker to initialize (may take 1-2 minutes)" "Yellow" + } else { + Write-ColorOutput "Warning: Could not find Docker Desktop executable" "Yellow" + Write-ColorOutput "You may need to start it manually from the Start menu" "Yellow" + } + } catch { + Write-ColorOutput "Warning: Could not start Docker Desktop automatically" "Yellow" + Write-ColorOutput "Please start it manually from the Start menu" "Yellow" + } +} + +Write-ColorOutput "`n========================================" "Cyan" +Write-ColorOutput "Installation Complete!" "Cyan" +Write-ColorOutput "========================================`n" "Cyan" + +if ($EnableWSL2) { + Write-ColorOutput "NOTE: A system restart may be required for WSL2 to work properly" "Yellow" + Write-ColorOutput "If Docker fails to start, please restart your computer" "Yellow" +} + +Write-ColorOutput "`nNext Steps:" "Cyan" +Write-ColorOutput "1. Wait for Docker Desktop to start and complete initialization" "White" +Write-ColorOutput "2. Sign in to Docker Desktop (optional)" "White" +Write-ColorOutput "3. Verify installation by running: docker --version" "White" +Write-ColorOutput "4. Test with: docker run hello-world`n" "White" + +# Offer to restart +$restart = Read-Host "Would you like to restart now? (Y/N)" +if ($restart.ToLower() -eq "y" -or $restart.ToLower() -eq "yes") { + Write-ColorOutput "Restarting system in 10 seconds..." "Yellow" + shutdown /r /t 10 /c "Restarting to complete Docker Desktop installation" +} else { + Write-ColorOutput "Please restart manually when convenient" "Yellow" +} diff --git a/install-rustdesk.ps1 b/install-rustdesk.ps1 new file mode 100644 index 0000000..b53e25f --- /dev/null +++ b/install-rustdesk.ps1 @@ -0,0 +1,254 @@ +# Install RustDesk Client on Windows +# RustDesk is an open-source remote desktop alternative to RDP +# Supports custom relay servers for secure connections +# Run as Administrator for system-wide installation + +param( + [string]$Version = "latest", + [string]$RelayServer = "", + [string]$ApiServer = "", + [string]$Key = "", + [switch]$InstallService = $true, + [switch]$StartAfterInstall = $true +) + +# Function to check if running as administrator +function Test-Administrator { + $currentUser = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + return $currentUser.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +# Function to write colored output +function Write-ColorOutput { + param([string]$Message, [string]$Color = "White") + Write-Host $Message -ForegroundColor $Color +} + +Write-ColorOutput "`n========================================" "Cyan" +Write-ColorOutput "RustDesk Client Installation Script" "Cyan" +Write-ColorOutput "========================================`n" "Cyan" + +# Check if running as administrator for system-wide install +if ($InstallService -and -not (Test-Administrator)) { + Write-ColorOutput "WARNING: Not running as Administrator" "Yellow" + Write-ColorOutput "Service installation will be skipped" "Yellow" + Write-ColorOutput "For full installation, run as Administrator`n" "Yellow" + $InstallService = $false + Start-Sleep -Seconds 2 +} + +# Determine download URL based on version +if ($Version -eq "latest") { + Write-ColorOutput "Fetching latest RustDesk version..." "Yellow" + try { + $apiUrl = "https://api.github.com/repos/rustdesk/rustdesk/releases/latest" + $release = Invoke-RestMethod -Uri $apiUrl -Method Get + $Version = $release.tag_name + Write-ColorOutput "Latest version: $Version" "Green" + } catch { + Write-ColorOutput "ERROR: Failed to fetch latest version" "Red" + Write-ColorOutput "Error: $_" "Red" + exit 1 + } +} else { + Write-ColorOutput "Using specified version: $Version" "Green" +} + +# Construct download URL for Windows installer +$downloadUrl = "https://github.com/rustdesk/rustdesk/releases/download/$Version/rustdesk-$Version-x86_64.exe" +$downloadPath = "$env:TEMP\rustdesk-installer.exe" + +Write-ColorOutput "`nDownloading RustDesk installer..." "Yellow" +Write-ColorOutput "URL: $downloadUrl" "Gray" + +try { + # Download with progress + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadPath -UseBasicParsing + $ProgressPreference = 'Continue' + Write-ColorOutput "Download completed successfully!" "Green" +} catch { + Write-ColorOutput "ERROR: Failed to download RustDesk" "Red" + Write-ColorOutput "Error: $_" "Red" + Write-ColorOutput "URL: $downloadUrl" "Yellow" + exit 1 +} + +# Verify download +if (-not (Test-Path $downloadPath)) { + Write-ColorOutput "ERROR: Downloaded file not found at $downloadPath" "Red" + exit 1 +} + +$fileSize = (Get-Item $downloadPath).Length / 1MB +Write-ColorOutput "Downloaded file size: $([math]::Round($fileSize, 2)) MB" "Green" + +# Install RustDesk +Write-ColorOutput "`nInstalling RustDesk..." "Yellow" + +$installArgs = @("--silent") + +if ($InstallService) { + $installArgs += "--install-service" +} + +try { + $process = Start-Process -FilePath $downloadPath -ArgumentList $installArgs -Wait -PassThru -NoNewWindow + + if ($process.ExitCode -eq 0) { + Write-ColorOutput "RustDesk installed successfully!" "Green" + } else { + Write-ColorOutput "WARNING: Installation completed with exit code $($process.ExitCode)" "Yellow" + } +} catch { + Write-ColorOutput "ERROR: Failed to install RustDesk" "Red" + Write-ColorOutput "Error: $_" "Red" + exit 1 +} finally { + # Clean up installer + if (Test-Path $downloadPath) { + Remove-Item $downloadPath -Force + Write-ColorOutput "Cleaned up installer file" "Green" + } +} + +# Wait for installation to complete +Start-Sleep -Seconds 2 + +# Configure custom relay server if provided +if ($RelayServer -or $ApiServer -or $Key) { + Write-ColorOutput "`nConfiguring custom relay server..." "Yellow" + + # RustDesk config file location + $configPath = "$env:APPDATA\RustDesk\config\RustDesk2.toml" + $configDir = Split-Path -Parent $configPath + + # Ensure config directory exists + if (-not (Test-Path $configDir)) { + New-Item -ItemType Directory -Path $configDir -Force | Out-Null + } + + # Build configuration + $config = "" + + if ($RelayServer) { + Write-ColorOutput "Setting relay server: $RelayServer" "Green" + $config += "relay-server = '$RelayServer'`n" + } + + if ($ApiServer) { + Write-ColorOutput "Setting API server: $ApiServer" "Green" + $config += "api-server = '$ApiServer'`n" + } + + if ($Key) { + Write-ColorOutput "Setting server key" "Green" + $config += "key = '$Key'`n" + } + + # Write or update config file + $existingConfig = "" + if (Test-Path $configPath) { + # Backup existing config + $backupPath = "$configPath.backup" + Copy-Item $configPath $backupPath -Force + Write-ColorOutput "Backed up existing config to $backupPath" "Gray" + + # Read existing config to preserve other settings + $existingConfig = Get-Content $configPath -Raw + + # Remove old relay/api/key settings if they exist (match only at start of line, not in comments) + $existingConfig = $existingConfig -replace "(?m)^\s*relay-server\s*=.*$", "" + $existingConfig = $existingConfig -replace "(?m)^\s*api-server\s*=.*$", "" + $existingConfig = $existingConfig -replace "(?m)^\s*key\s*=.*$", "" + # Remove extra blank lines + $existingConfig = $existingConfig -replace "(?m)^\s*$\n", "" + $existingConfig = $existingConfig.Trim() + } + + try { + # Combine existing config (without duplicates) and new settings + $finalConfig = if ($existingConfig) { "$existingConfig`n$config" } else { $config } + Set-Content -Path $configPath -Value $finalConfig.Trim() -Encoding UTF8 + Write-ColorOutput "Configuration saved successfully!" "Green" + } catch { + Write-ColorOutput "WARNING: Failed to write configuration" "Yellow" + Write-ColorOutput "Error: $_" "Yellow" + Write-ColorOutput "You may need to configure the relay server manually" "Yellow" + } +} + +# Start RustDesk if requested +if ($StartAfterInstall) { + Write-ColorOutput "`nStarting RustDesk..." "Yellow" + Start-Sleep -Seconds 1 + + try { + # Try multiple possible installation paths + $possiblePaths = @( + "C:\Program Files\RustDesk\rustdesk.exe", + "$env:ProgramFiles\RustDesk\rustdesk.exe", + "$env:LocalAppData\RustDesk\rustdesk.exe" + ) + + $rustdeskFound = $false + foreach ($path in $possiblePaths) { + if (Test-Path $path) { + Start-Process $path + Write-ColorOutput "RustDesk started successfully!" "Green" + $rustdeskFound = $true + break + } + } + + if (-not $rustdeskFound) { + Write-ColorOutput "Warning: Could not find RustDesk executable" "Yellow" + Write-ColorOutput "You may need to start it manually" "Yellow" + } + } catch { + Write-ColorOutput "Warning: Could not start RustDesk automatically" "Yellow" + Write-ColorOutput "Please start it manually from the Start menu" "Yellow" + } +} + +Write-ColorOutput "`n========================================" "Cyan" +Write-ColorOutput "Installation Complete!" "Cyan" +Write-ColorOutput "========================================`n" "Cyan" + +Write-ColorOutput "RustDesk Information:" "Cyan" +Write-ColorOutput "- RustDesk is now installed on your system" "White" +Write-ColorOutput "- You can find it in the Start menu" "White" + +if ($InstallService) { + Write-ColorOutput "- Service is installed and will start automatically" "White" +} + +if ($RelayServer) { + Write-ColorOutput "`nCustom Relay Server:" "Cyan" + Write-ColorOutput "- Relay: $RelayServer" "White" + if ($ApiServer) { + Write-ColorOutput "- API: $ApiServer" "White" + } + Write-ColorOutput "- Your RustDesk ID will be shown when you start the application" "White" +} + +Write-ColorOutput "`nNext Steps:" "Cyan" +Write-ColorOutput "1. Launch RustDesk from the Start menu (if not auto-started)" "White" +Write-ColorOutput "2. Note your RustDesk ID from the main window" "White" +Write-ColorOutput "3. Share your ID with others to allow remote connections" "White" +Write-ColorOutput "4. Set a password for secure unattended access (optional)" "White" + +if (-not $RelayServer) { + Write-ColorOutput "`nCustom Relay Server Setup:" "Cyan" + Write-ColorOutput "To configure a custom relay server later, you can:" "White" + Write-ColorOutput "1. Run this script again with -RelayServer parameter" "White" + Write-ColorOutput "2. Or configure manually in RustDesk settings`n" "White" + Write-ColorOutput "Example: .\install-rustdesk.ps1 -RelayServer 'your-server.com' -Key 'your-key'" "Gray" +} + +Write-ColorOutput "`nRustDesk vs RDP:" "Cyan" +Write-ColorOutput "- RustDesk works over the internet (NAT traversal)" "White" +Write-ColorOutput "- Custom relay servers for privacy and security" "White" +Write-ColorOutput "- Cross-platform (Windows, macOS, Linux, iOS, Android)" "White" +Write-ColorOutput "- Open-source and free" "White" +Write-ColorOutput "- Alternative to TeamViewer, AnyDesk, and traditional RDP`n" "White" diff --git a/readme.md b/readme.md index adbb6bf..1e5bbc5 100644 --- a/readme.md +++ b/readme.md @@ -20,6 +20,12 @@ Windows inside a Docker container. - KVM acceleration - Web-based viewer +> [!NOTE] +> **New!** See [SETUP.md](SETUP.md) for additional setup guides including: +> - Environment-based configuration with .env file +> - Docker Desktop installation script for Windows +> - RustDesk setup (RDP alternative with custom relay server support) + ## Video 📺 [![Youtube](https://img.youtube.com/vi/xhGYobuG508/0.jpg)](https://www.youtube.com/watch?v=xhGYobuG508) @@ -50,6 +56,9 @@ services: stop_grace_period: 2m ``` +> [!TIP] +> **Using .env for configuration:** You can use environment variables for easier configuration management. See the included `compose.yml` and `.env.example` files, or read the [environment configuration guide](SETUP.md#environment-based-configuration) for details. + ##### Via Docker CLI: ```bash @@ -255,6 +264,23 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/mas There is a RDP client for [Android](https://play.google.com/store/apps/details?id=com.microsoft.rdc.androidx) available from the Play Store and one for [iOS](https://apps.apple.com/nl/app/microsoft-remote-desktop/id714464092?l=en-GB) in the Apple Store. For Linux you can use [FreeRDP](https://www.freerdp.com/) and on Windows just type `mstsc` in the search box. +### What are the alternatives to RDP for remote access? + + Besides traditional RDP (port 3389), you can use **RustDesk** as an open-source alternative that offers several advantages: + + - **NAT Traversal**: Connect over the internet without port forwarding or VPN + - **Custom Relay Servers**: Host your own relay server for complete privacy and control + - **Cross-Platform**: Available for Windows, macOS, Linux, iOS, and Android + - **Free & Open-Source**: No licensing costs or restrictions + - **Easy Setup**: Works out-of-the-box without complex network configuration + + RustDesk is particularly useful when: + - You need to access your Windows container from outside your local network + - Traditional RDP port (3389) is blocked or unsafe to expose to the internet + - You want to use your own relay server instead of VPN or cloud services + + See the [RustDesk setup guide](SETUP.md#rustdesk-alternative-remote-desktop-solution) for installation instructions and configuration with custom relay servers. + ### How do I assign an individual IP address to the container? By default, the container uses bridge networking, which shares the IP address with the host.