Overview
Running graphical Docker containers on Windows requires Docker Desktop with WSL2 backend and an X server for display forwarding. This guide covers the complete setup process for Windows users.Prerequisites
Before you begin, ensure you have:- Windows 10 version 2004 or higher, or Windows 11
- WSL2 installed and configured
- Docker Desktop for Windows installed
Setup Steps
Install WSL2
WSL2 (Windows Subsystem for Linux 2) is required for Docker Desktop on Windows.Open PowerShell as Administrator and run:This command will:You should see your Linux distribution listed with version 2.
- Enable the WSL feature
- Install the Ubuntu distribution (default)
- Set WSL2 as the default version
Install Docker Desktop
Download and install Docker Desktop for Windows:
- Download from https://www.docker.com/products/docker-desktop/
- Run the installer
- Ensure “Use WSL 2 instead of Hyper-V” is selected during installation
- Restart your computer when prompted
- Open Docker Desktop
- Go to Settings → General
- Ensure “Use the WSL 2 based engine” is checked
- Go to Settings → Resources → WSL Integration
- Enable integration with your WSL2 distributions
Install an X Server
Windows doesn’t have a native X server, so you need to install one. We recommend VcXsrv.
VcXsrv (Recommended)
VcXsrv (Recommended)
Download and Install:
- Download VcXsrv from SourceForge
- Run the installer with default settings
- Launch XLaunch (VcXsrv)
- Select “Multiple windows” → Next
- Select “Start no client” → Next
- Important: Check these boxes:
- “Clipboard” (optional, for clipboard sharing)
- “Primary Selection” (optional)
- “Disable access control” (required for Docker containers)
- Click “Finish”
Xming (Alternative)
Xming (Alternative)
Download and Install:
- Download Xming from SourceForge
- Run the installer
- Run Xming from the Start menu
- You should see the Xming icon in your system tray
- Configure it to disable access control for Docker
Configure Display Environment
You need to set the DISPLAY environment variable to point to your Windows X server.Open your WSL2 terminal and add this to your Alternatively, if you’re using WSL2 with localhost access (newer versions):Apply the changes:
~/.bashrc or ~/.profile:The DISPLAY variable tells Docker containers where to send graphical output. It points to your Windows X server.
Running the Container
From your WSL2 terminal, run the container with the following command:-it: Starts the container in interactive mode with a terminal attached--rm: Automatically removes the container when it exits-e DISPLAY=$DISPLAY: Passes the DISPLAY variable to the container-v /tmp/.X11-unix:/tmp/.X11-unix: Mounts the X11 socket directory-v ./user_code:/app/user_code: Mounts your code directory into the containerraylib_container: The name of the Docker image
Verifying Graphics Connection
Once inside the container, test the graphics connection:Hardware Acceleration
Current Limitations
- Direct GPU passthrough to containers is not fully supported on Windows
- The
--device /dev/dri:/dev/driflag used on Linux won’t work - Graphics rendering will primarily use CPU (software rendering)
Improving Performance
While hardware acceleration isn’t fully available, you can improve performance:-
Allocate more resources to Docker:
- Open Docker Desktop → Settings → Resources
- Increase CPU count and Memory allocation
-
Allocate more resources to WSL2:
Create/edit
%USERPROFILE%\.wslconfig:Restart WSL2: -
Use lower resolutions during development:
- Test with smaller window sizes
- Reduce asset complexity
Common Workflows
Starting a Development Session
Open WSL2 Terminal
Open your WSL2 distribution (e.g., Ubuntu) from the Start menu or Windows Terminal.
Navigate to Your Project
Your Windows drives are mounted under
/mnt/ in WSL2. For example, C:\ is /mnt/c/.Creating a Launch Script
Create a script to simplify launching:Troubleshooting
Error: Cannot connect to Docker daemon
Error: Cannot connect to Docker daemon
Full error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sockSolutions:- Ensure Docker Desktop is running (check system tray)
- Verify WSL integration is enabled in Docker Desktop settings
- Restart Docker Desktop
- In WSL2, run:
docker psto verify connection
Graphics window doesn't appear
Graphics window doesn't appear
Symptoms: Container runs but no graphics window appearsSolutions:
- Verify VcXsrv is running (check system tray for X icon)
- Check DISPLAY variable:
Should show an IP address or
:0 - Ensure VcXsrv has “Disable access control” checked
- Check Windows Firewall:
- Allow VcXsrv through the firewall
- Settings → Update & Security → Windows Security → Firewall & network protection
- Try using localhost:
Error: Can't open display
Error: Can't open display
Full error:
Error: Can't open display: <IP>:0Solutions:- Restart VcXsrv with access control disabled
- Verify the DISPLAY IP matches your Windows host:
- Try alternative DISPLAY configurations:
- Check that VcXsrv is listening on the correct port (6000)
Slow graphics performance
Slow graphics performance
Cause: Software rendering without GPU accelerationSolutions:
- This is expected on Windows with Docker
- Increase Docker Desktop resources (Settings → Resources)
- Edit
.wslconfigto allocate more memory/CPU to WSL2 - Reduce window size and graphics complexity
- For production testing, use a Linux machine
WSL2 not found / not installed
WSL2 not found / not installed
Solutions:
- Ensure Windows version is 2004 or higher:
- Press Win+R, type
winver, check version
- Press Win+R, type
- Run in PowerShell (Admin):
- Verify installation:
- Reboot after installation
File Paths and Volume Mounting
Accessing Windows Files from WSL2
Your Windows drives are mounted under/mnt/:
Recommended Project Structure
Store your projects in the WSL2 filesystem for better performance:Known Limitations
Workarounds
- For performance-critical development, consider dual-booting Linux or using a Linux VM
- Use Windows-native tools for final builds and testing
- Keep development assets minimal to reduce rendering load
- Consider developing natively on Windows and using the container for CI/CD
Next Steps
Build the Image
Learn how to build the Raylib Container image
Quick Start
Create your first Raylib project