Add USB device passthrough support for WSLC
Is your feature request related to a problem? Please describe. Yes. There is currently no apparent way to pass USB devices into WSLC containers. This limits the usefulness of WSLC for hardware-related workloads.
For example, USB devices can be attached to WSL successfully using usbipd-win:
usbipd attach --wsl --busid <busid>
The device is visible inside a normal WSL distribution:
lsusb
However, inside a WSLC container, the USB device is not visible:
lsusb
returns no devices, and:
ls /dev/bus/usb
returns:
No such file or directory
Currently, wslc run --help provides options such as --gpus and --volume, but there does not appear to be an equivalent to Docker's --device option.
This prevents WSLC containers from being used for many hardware-accelerated Linux workloads, such as robotics, cameras, embedded development, and scientific instruments.
Describe the solution you'd like
I would like WSLC to provide a way to pass USB devices (or more generally Linux device nodes) into containers.
A Docker-compatible approach would be:
wslc run --device /dev/bus/usb ...
or a WSLC-specific mechanism such as:
wslc run --usb all ...
The solution should allow devices already attached through usbipd-win to WSL to be selectively exposed to WSLC containers.
A more general device passthrough mechanism (similar to Docker's --device or --privileged) would also be useful for:
- USB cameras (
/dev/video*) - USB serial devices (
/dev/ttyUSB*) - development boards
- FPGA/JTAG adapters
- industrial sensors
Describe alternatives you've considered Using Docker Desktop with WSL2 is currently the main alternative. Docker already supports device passthrough through options such as:
--device
--privileged
However, this introduces another container runtime layer on top of WSL.
One of the main advantages of WSLC is that it is a native Windows-managed Linux container environment with direct integration into WSL features such as GPU support. Adding device passthrough would make WSLC a more complete alternative for hardware-enabled Linux containers. Another workaround is running applications directly inside a WSL distribution instead of a container, but this loses the isolation and reproducibility benefits of containers.
Additional context Environment:
- Windows 11
- WSLC version:
2.9.3.0 - USB forwarding:
usbipd-win
WSLC has great potential for workloads that combine:
- GPU acceleration
- Linux environments
- Windows hardware integration Examples:
- ROS2 robotics
- NVIDIA Isaac / FoundationPose
- RealSense and depth cameras
- USB cameras
- embedded Linux development
- FPGA tools
Adding USB/device passthrough support would significantly expand the practical use cases of WSLC : )
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues
Once completed please upload the output files to this GitHub issue.
See Collect WSL logs (recommended method).
If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.
/feature
Diagnostic information
Found '/feature', adding tag 'feature'
I absolutely second this feature request. Actually we use wsl with podman and dev containers and have to use usbipd to route the usb debuggers to the container.
This works fine so far except when unplug and replug the usb device while having the dev container running. this does not work, but it would be perfect, if wslc were able to handle such a situation.
Confirmed there is no way to pass USB devices into wslc containers as of 2.9.4.0. The gap is architectural: wslc containers run in a per-session Hyper-V utility VM that shares neither the WSL distro filesystem nor its devices. So even after usbipd attach --wsl, lsusb returns no devices and /dev/bus/usb does not exist inside the container.
The workaround today is to run the USB workload in a normal WSL distro (where usbipd-win works), or keep Docker Desktop for the rare USB-in-container case since Docker still supports --device.
Two things would need to land for this to work: a --device flag (currently rejected as unrecognized on 2.9.4.0 — see #41181), and a /dev/bus/usb mapping in the session VM. #41216 discusses building USB attach into WSL itself, which would presumably reach the utility VM too.
(I keep a write-up of what works and what doesn't at https://wslcontainers.com/guides/usb-passthrough/ — happy to update it when USB support lands.)
This is more of a broader USB support thing so assigning to @OneBlue to evaluate request.
I absolutely second this feature request. Actually we use wsl with podman and dev containers and have to use usbipd to route the usb debuggers to the container.
Yep agree. For embedded devs that's the only route beside network based debuggers currently. And imo that's not a rare case.
Looks like the wslc devs completely forgot embedded devs workflows which is a pity, because wslc would have had a great chance to fly in corporate environments. But without USB support it won't - at least in any company doing system/embedded stuff.
I would have loved to ditch podman and rather complex nested virtualization/container tools for a native solution :( I hope so much the USB requirement will be considered in the future.
This works fine so far except when unplug and replug the usb device while having the dev container running. this does not work, but it would be perfect, if wslc were able to handle such a situation.
It does work using a small daemon in the container and mounting /dev with rslave. Not ideal, but better than privileged imo. Ping me if you need more details.
Another vote for this feature.