Accessing USB webcam hosted on OS X from a Docker container - macos

Is it possible to access a USB camera (e.g Logitech c270) from a Docker container?
The camera is connected to a Mac host via a USB port.
Even when running the container with --privileged, i could not find the device (e.g /dev/video0 file does not exist).
Thanks

The default docker-machine creates a virtual machine with official boot2docker.iso. And this slim distro doesn't support USB video device. When you attach the USB device to the virtual machine, the kernel can't do anything without the right driver. So, you won't see any video capturing device, such as /dev/video0.
TL;DR
I've compiled a customized boot2docker.iso which ships uvcvideo driver. Use this one to create you docker machine.
docker-machine create -d virtualbox --virtualbox-boot2docker-url https://github.com/Alexoner/boot2docker/releases/download/v17.06.0-ce-usb-rc5/boot2docker.iso default
Then install the VirtualBox extension, attach the webcam device, you are good to go!
Reference
Attach webcam: https://www.virtualbox.org/manual/ch09.html#webcam-passthrough

Related

How to share Docker for Mac images with ones in docker-machine?

So I am on a mac and I need USB forwarded into docker image. Thus I spin up docker-machine on virtualbox with usb forwarding. The only thing is that it does not see my docker images from Docker for Mac and I really would like to share them. How to do such thing?

How to view USB devices in a Docker container, Windows Hyper-V host?

I'm trying to do this: Docker - any way to give access to host USB or serial device?
I want to develop an application with Ionic but I cannot see my device (or any usb, lsusb) running adb devices.
Do I need to map a USB folder to the container (like -v /dev/bus/usb:/dev/bus/usb)?
But how do I do that on Windows?
afaik Hyper-V cannot "handle"/forward/map USB devices. Thus my guess is it will not work in containers either.

Pass USB device into a Docker Windows Container

I'm on Windows 10 using Docker for Windows. Also, I have a container which originates FROM microsoft/windowsservercore. I have an USB device attached and want to pass it to that container.
What I found so far:
Under Linux you got --device=/dev/.., but how can I accomplish this under Windows?
Michael Friis wrote on 2017-07-07 that this is currently not possible. However, this comment states that it is.
So my questions are:
Is it currently possible to pass an USB device from a Windows Host into a Windows Docker container?
If yes, what is the correct syntax?
If not, when approximately can we expect this feature?
You cannot directly pass USB to the container. Either you have to run Docker as a VM or use USB/IP (where the USB data is transferred as IP packets). But there will be a delay in the second method.
I spent a day trying to figure out this problem, unfortunately there is no way to passthru USB devices to Windows containers as for now (Sep 2022).
Hyper-V doesn't support USB Passthru per se. While USB-IP seems like a viable solution, it requires installing custom drivers (usually self-signed), which is not support with Windows containers.
USB passthrough is currently not supported with Windows for Docker as of November 2017:
Docker for Windows USB Support
There is a way to pass USB through to Docker for Desktop running on windows. If the docker engine is running using WSL2 (Settings -> General -> Use the WSL 2 based engine) then you can attach a usb device using the usbipd libraries.
Details on USBIPD library and download:
https://learn.microsoft.com/en-us/windows/wsl/connect-usb
I went into Command Prompt and typed in:
usbipd wsl list
Found the USB device that I wanted available in my docker container and then attached it in usbipd using the command:
usbipd wsl attach --busid <bus-id>
In the docker compose script I have:
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
Which is where the usb device is being seen when I go into the container and go to /dev I see that ttyUSB0 is listed.
I can now use that USB device.. the trick is that the device needs to be attached using the usbipd command before the container starts or you will need to restart the containers for the container OS to see everything.
If you have that devices statement in your compose you might fine to attach and detach using usbipd and it just works since it would take the ttyUSB0 each time.

how to access OSX non-storage devices from docker container

I'm currently trying to run a USB Scale and USB Barcode scanner on a docker container hooked up to my MacBook Pro. I see how to do it on linux, by using the --device or --privileged flag, but I can't seem to figure out where exactly these devices reside on my mac since they are not storage devices. Any ideas?

How to eject a USB HID Device from Mac OSX to use in Ubuntu VM?

I'm running Ubuntu 14.04LTS, 64bit via VirtualBox on a mac. I want to talk to a USB HID device from my VM via a python app (pyusb) but I can't select the device. From VirtualBox -> Devices -> USB Devices I see my device but it's grayed out.
I was hoping to find a command I could run on the mac terminal to 'let go' of it, but it's turning out to be more difficult than I imagined. On an Ubuntu VM via Windows 7, I can take control of the USB HID device via Devices -> USB Devices -> Select my device and talk to it just fine.
Is there some reason why this may not be possible on a mac?
There is no concept of 'unmount in host OS to grab it in vm's OS'.
To get a normally plug-and-play device to work:
Shut down the guest machine.
Highlight the guest machine in the VirtualBox panel.
Go to Settings for that vm -> Ports -> USB
Click the green plus icon to add your device.
Your usb device should now be visible, click to add that.
Remove the USB device from your physical machine
Start VB and guest OS (in my case Ubuntu 14.04 LTS, 64bit)
Plug in USB device
Inspect that the device has been captured by the vm's operating system in Devices -> USB Devices

Resources