Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i pass through USB device in docker for windows(Hyper -v ) #3926

Open
br13patel opened this issue May 17, 2019 · 40 comments
Open

how can i pass through USB device in docker for windows(Hyper -v ) #3926

br13patel opened this issue May 17, 2019 · 40 comments

Comments

@br13patel
Copy link

Setup:

Docker for windows version: 18.09.2
Host: Windows 10, Version 1803 (OS build 17134.765)
Container: Linux/Ubuntu container.

Whenever i insert USB device it will not detect on my linux container. I have tried with many docker run command line option(e.g --device, -V : ), But still the behavior is the same.

USB device is detected if my host OS is Ubuntu and windows 7(with docker toolbox). I have also tried to debug this and dump kernel log but there is no log of my USB device.

@mikeparker
Copy link
Contributor

Can you elaborate on exactly the reproduction steps?
-> Plug in the USB device
-> Share the USB device from drive sharing inside Docker Desktop
-> A container cannot access the new drive?

@rajasec
Copy link

rajasec commented Jun 20, 2019

I have the same issue, not sure whether Hyper-V allows USB pass through due to which MobyVM not able to access the devices

@rajasec
Copy link

rajasec commented Jun 20, 2019

If it is Windows 10, I'm able to USB flash drive after applying the below steps

  1. Click Docker Desktop settings
  2. Click the new Drive and Apply.
  3. After that launch the container by passing the drive name:
    For Eg:
    docker run -ti -v D:/personal: /data ubuntu bash
    With this I'm able to access the flash drive

@eine
Copy link

eine commented Aug 19, 2019

For USB devices which are not for storage, USB over network might be a usable workaround until sharing the devices is supported by default. See https://github.com/ghdl/docker/tree/feat-usbip/usbip.

Ref #4105.

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@Tam66662
Copy link

Tam66662 commented Dec 4, 2019

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@eine
Copy link

eine commented May 3, 2020

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@eine
Copy link

eine commented Aug 1, 2020

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@eine
Copy link

eine commented Oct 30, 2020

/remove-lifecycle stale

@androniychuk
Copy link

According to this doc, it's not supported
https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/hardware-devices-in-containers

But technically since you pass an id into a windows container, you should be able to do the same with Linux. Just need to figure out how the backend works.

@amirhs712
Copy link

I could really use this feature if it was added.
I have a .NET project which requires access to a security token via USB, but It won't work on windows containers.

@heyinzeng
Copy link

/remove-lifecycle stale

@mschweig
Copy link

I would also need this feature.
Windows 10 Host and Ubuntu Container

@petriceko
Copy link

petriceko commented May 10, 2021

Any update?

@mfiumara
Copy link

Hey I think this is a limitation of windows not necessarily docker so until windows fixes USB devices for WSL you will have to do with usb over IP solutions (which are far from ideal).

@JPHutchins
Copy link

JPHutchins commented Jul 15, 2021

I am researching the use case "firmware development" and since USB passthrough is necessary for attaching programmers and serial I am interpreting that my best approach with a Windows Host will be a hypervisor with good USB passthrough to a Linux VM that then hosts the Docker containers.

USB: Windows->VMWare->LinuxVM->Docker->DockerContainer
SSH: Windows->DockerContainer

Is this a reasonable interpretation of the state until Windows Docker Desktop benefits from a hypothetical WSL update?

@eine
Copy link

eine commented Jul 15, 2021

@JPHutchins it is. However, I'm not sure you can have an hypervisor with good USB passthrough. It that was feasible, I would have expected either Docker or Microsoft to provide that capability already.

Alternatively, you might want to patch the LinuxVM for supporting USB/IP. See https://hdl.github.io/containers/ug/index.html#_usbip_protocol_support_for_docker_desktop. The challenge in this case is finding an open source USB/IP tool on Windows, but it works ok if you are good with using a non open source tool.

@amirhs712
Copy link

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@Bortronx
Copy link

/remove-lifecycle stale

@davidnaumann-bastian
Copy link

davidnaumann-bastian commented Mar 29, 2022

Would recommend this approach: Microsoft Dev Blog: Connecting USB devices to WSL and just pick up those USB devices in WSL2.

I'd say until Microsoft officially supports pushing USB devices down to the WSL level this is the best and only approach as the time of writing this.

@znmeb
Copy link

znmeb commented Jun 23, 2022

Would recommend this approach: Microsoft Dev Blog: Connecting USB devices to WSL and just pick up those USB devices in WSL2.

I'd say until Microsoft officially supports pushing USB devices down to the WSL level this is the best and only approach as the time of writing this.

USB support in WSL is poorly documented and not solid. It does not as of this writing solve the problem.

@davidnaumann-bastian
Copy link

Would recommend this approach: Microsoft Dev Blog: Connecting USB devices to WSL and just pick up those USB devices in WSL2.
I'd say until Microsoft officially supports pushing USB devices down to the WSL level this is the best and only approach as the time of writing this.

USB support in WSL is poorly documented and not solid. It does not as of this writing solve the problem.

Yes, agreed with the sentiment expressed. Should've added that the only reason I recommended that approach is that it is the only approach I found to go about this problem.

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@esarver
Copy link

esarver commented Sep 22, 2022

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

@ArjanBlokJump
Copy link

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

@znmeb
Copy link

znmeb commented Mar 21, 2023

Close this wontfix or work on it ... Letting a robot mark it stale is not a response!

@AShriki
Copy link

AShriki commented Mar 24, 2023

/remove-lifecycle stale

@AShriki
Copy link

AShriki commented Mar 24, 2023

I see the original poster has not elaborated on the request for information and has probably abandoned this issue. My specific use case is to generalize embedded development environments with a debugger (see segger j-link for an example here). These devices use vendor supplied drivers. I would also be interested in passing through any generic USB device similarly to how you can pass a USB device from the host into a VirtualBox guest OS (this guide is a simplistic overview in general and not specific to a windows host).

> Can you elaborate on exactly the reproduction steps?
-> Plug in the USB device
The J-link usb device is plugged into a USB port on the computer
-> A container cannot access the new drive?
Not relevant, but no USB device is seen in /dev/ and I can't find a way to allow the docker container to use/take ownership of the device.

What I would like is a way to specify a USB device connected to the host for use (exclusive or not. No preference here) within the container.

Let me know what other information is needed.

@androniychuk
Copy link

Would like to post my thoughts on this.
I originally needed such an implementation for the purpose of Ubuntu running on WSL and accessing the graphics driver. However, there is now another implementation of this, that works great. Its the WSL driver for your GPU:
https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
This doesn't work on all systems, but it works pretty great on my Intel GPU and accomplishes the "pass-through" that I needed.

@docker-robot
Copy link

docker-robot bot commented Jun 23, 2023

There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
If not, this issue will be closed in 30 days.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

@exzhawk
Copy link

exzhawk commented Jun 23, 2023

/remove-lifecycle stale

@AkifManzoor124
Copy link

/remove-lifecycle stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests