Docker Community Forums

Share and learn in the Docker community.

Unable to mount single usb device to the container when multiple usb devices are connected to the host machine in privileged mode

unable to mount single usb device to the container when multiple usb devices are connected to the host machine in privileged mode

appreciate your help

docker commnad:

docker run -idt --net=host --privileged -v /dev/bus/usb:/dev/bus/usb
–name test
-v /home/test/:/home/test/
test_image

-1

From all the researches online and some experimentation with using ‘–device’, I’ve found that ephemeral (hot pluggable) devices are not supported by this option. It’s a incomplete info Docker documentation did not state this clearly, if at all. I only read one comment online from a user which mentioned it in passing. For those who want to use ‘–device’ for these devices, don’t; use the ‘–privileged’ & '-v ’ options instead. This will avoid you having to specify the exact device file name, e.g. /dev/bus/usb/002/088, instead you can specify just /dev/bus/usb

Still Im looking for more suggestion on this topic ,

Like how to handle multiple device with multiple container on the same host machine

I was able to figure this out. If we run in privileged mode, all USB busses are available to the container.

We just need to delete the unwanted bus from the container. Though the volume is in sync, this deletion will not effect the USB bus in Docker host.

1 Like

Yes it will affect, In my cases

  1. I’m able to launch two containers by allocating two different devices to it with --privilege mode. But problem is
    when i list devices it is listing same devices in both container even Devpath is different .

docker run -idt --net=host --privileged -v /dev/bus/usb/002/088:/dev/bus/usb/002/088 -v /run/udev:/run/udev:ro --name test12 test_image.

output on both container is same even after restarting the adb server