Febin K G
Febin K G

Reputation: 93

Using docker run --privileged to host a single USB device

I was able to host my USB device with the help of this Stack Overflow post

docker run -t -i --privileged -v /dev/bus/usb:/dev/bus/usb ubuntu bash

This hosts all the connected USB devices.

Is there a way in which I can host one particular device?

Let's say the USB file resides in /dev/bus/usb/002/005. I would like this file alone to be hosted on my container.

I tried docker run -t -i --privileged -v /dev/bus/usb/002/005:/dev/bus/usb/002/005 ubuntu bash, but it still hosts the entire usb directory.

Upvotes: 4

Views: 7384

Answers (1)

mviereck
mviereck

Reputation: 1399

Try --device /dev/bus/usb/002/005.

Side note: Docker version 1.17 from the Ubuntu repository has a bug with option --device that does not set group ownership of a shared device in a container to the same as on the host. If you have issues for this reason, try:

--device /dev/bus/usb/002/005 --volume=/dev/bus/usb/002/005:/dev/bus/usb/002/005

Never use --privileged for anything except short debugging tests.

Upvotes: 4

Related Questions