I've not been able to locate any instructions on how to access a USB device from Docker in Windows, exactly, although the instructions here, despite being from Mac OS X, come pretty close.
So I'm trying this on Windows, and here's what I've done so far:
- Upgraded Oracle VirtualBox to 5.0.16, and installed the Oracle VM VirtualBox Extensions Pack, which allows the boot2docker VM the ability to use USB 2.0 to access my device.
- Powered off the
default
virtual machine, and went to Machine → Settings… → USB. Added new USB filter, by selecting the machine from the pop-up list. - Restarted the Docker Quickstart Terminal.
The thing is, I suspect that the command for running the virtual machine instance is something as follows:
docker run --privileged -v <USB directory in host machine>:<USB directory in Docker container> ...
The problem is, while in Mac OS X it appears to be /dev/bus/usb
, where does it appear in Windows? Isn't it the same place? The /dev/
directory doesn't appear to have /dev/usb/
.
Have I missed a step? Is the USB device path in a different place for Windows?
By the way, this is the version of Docker that I'm using when I type docker -v
:
Docker version 1.10.0, build 590d5108
I'm also currently using Windows 7.
Looks like biting the bullet, despite not seeing /dev/bus/usb and typing the following command works:
(in my case, it was
docker run-it --privileged -v /dev/bus/usb:/dev/bus/usb -v (shared directory path):(path in container) debian:latest bash
, but your command will be different depending on what you're doing).Also, if you're working on Android devices and you want to still access them when they're on the bootloader, you will need to create two filters within VirtualBox: one for when you're using ADB, the other when you're using fastboot.
I was able to get this working on a Windows host with Docker Toolbox which I'm assuming the OP is using.
Stop the boot2docker vm:
Open VirtualBox manager and add USB filters as required.
Start the boot2docker vm:
Since the USB devices are connected to the boot2docker VM, the commands need to be run from that machine. Open up a terminal with the VM and run the Docker run command:
If you want the Docker container to work with USB devices plugged in after the container is started you can use:
Most other examples I see are using
-v /dev/bus/usb:/dev/bus/usb
which will only work for certain USB devices. I had to use/dev
for an application that created/dev/sg2
when the USB port was plugged in.Note, the flags
-it
are only required as an example here so that you can get a Bash terminal inside an Ubuntu container. They are not actually required for this to work.