USB/IP on Docker Desktop WSL2 backend

This is a general discussion/feature request, but since it is specific to Docker Desktop for Windows, i’m opening it here. Feel free to move it somewhere more appropriate :slight_smile:

I have recently had reason to pass a non-storage usb device to a linux docker container on windows.
Looking around for ways to achieve this, the official docker documentation flat out states wsl2 does not support this.

This, however, is untrue. Microsoft has released official guidance on using USP/IP to expose usb devices to WSL2 distros in late 2021 (Documentation, Blog post)

I have tried this myself, and successfully passed a usb device to a docker container running inside an ubuntu WSL2 distro. Specifically, i passed a Nabucasa SkyConnect stick to a HomeAssistant container on Ubuntu 20.04 LTS.

It is my understanding that the docker-distro Docker Desktop uses to run containers essentially runs and exposes a docker daemon and is in effect just “remote controlled” by the docker components installed in windows.
Assuming that is about correct, is there any (technical) barrier to including the needed packages in the docker-distro to achieve the same thing? This looks like a fairly simple way to achieve a lot of functionality.

Needing to use an external tool (usbipd) would be somewhat clunky from a user experience point of view, but i doubt anyone needing this functionality would complain about that too loudly.

I have seen user stories of trying to containerise applications that require physical usb keys as a means of licensing (i thought that died out in the 90’s…). Other use cases are running radio devices with linux software or micro controller programming.

Welcome to the forum and thank you for sharing your request! We can talk about it here, but if you realyl want this feature implemented eventually, I would recommend you to post it also in the roadmap:

Docker Desktop is based on LinuxKit,

which is based on Alpine. If the feature cannot be implemented, tit is possible that Alpine or LinuxKit makes it difficult, but I don’t know the answer.

Can you quote that statement with a link to the documentation?

Thank you for your reply @rimelek,

the USB/IP client used in the linked documentation is available for Alpine,
so i don’t see that blocking this. If anything, i would expect an incompatibility or security implications
preventing this from becoming a feature, but we’ll see. I will definitely take your advice and post this on the roadmap!

Regarding the docs, i found the original quote, it’s actually on the general FAQ and states the following:

Can I pass through a USB device to a container?
Unfortunately, it is not possible to pass through a USB device (or a serial port) to a container as it requires support at the hypervisor level.

That is obviously wrong for linux containers on linux hosts. The FAQ does generally seem quite outdated, with the Windows FAQ stating Docker Desktop were not supported on Windows Server.

Is it actually supported on Windows Server? I haven’t seen any official statement about it yet. I know that Windows Server 2022 supports WSL, so Hyper-V was supported before and Docker Desktop wasn’t. I also know that people try to install it on Windows server and some succeeds but I still can’t find an official statement regarding Windows server. It’s like running Linux containers on a non-supported distribution which is based on a supported distribution.

Thanks for the link.

Docker tries to give you the same experience on all platforms (I know, it is not exactly the same) so that statement could be because they should support it on every platform. Or… as you assume, the FAQ could be outdated so it is definitely a good idea to take this request to the roadmap.