1

In a Docker container:

docker run --rm -it --privileged debian bash
root@fe612fde137f:/# apt-get update && apt-get install -y usbutils && lsusb
... snip ...
Bus 001 Device 001: ID 1d6b:0002  
Bus 002 Device 012: ID 1a86:5512  
Bus 002 Device 003: ID 0e0f:0002  
Bus 002 Device 002: ID 0e0f:0003  
Bus 002 Device 001: ID 1d6b:0001  
root@fe612fde137f:/# 

On the host:

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 012: ID 1a86:5512 QinHeng Electronics CH341 in EPP/MEM/I2C mode, EPP/I2C adapter
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$

Any idea how to get USB device descriptions from inside the Docker container?


Solution: usb.ids is present, but not hwdb.bin (hardware database).

docker run --rm -it --privileged debian bash
root@fe612fde137f:/# apt-get update && apt-get install -y usbutils && find / -type f \( -name "usb.ids" -o -name "hwdb.bin" \)
/var/lib/usbutils/usb.ids
root@fe612fde137f:/# 

This means udev is not installed. To fix, apt install udev on debian.

1 Answer 1

1

Have /usr/share/usb.ids (and/or [/usr]/lib/udev/hwdb.bin if your distribution has it) be present within the container.

If your container works well otherwise, it seems you only need those files for lsusb. While adding the udev package to be included into the container build process is possible, it might be overkill in this case.

The hwdb.bin file is created dynamically by the systemd-hwdb update command, sourcing the information from /lib/udev/hwdb.d/*.hwdb and /etc/udev/hwdb.d/*.hwdb files. To keep the container as lightweight as possible, you might want to create the hwdb.bin outside the container (or use the file from your container builder host) and just inject the end product hwdb.bin into the actual container.

I ran lsusb under strace to find out all the locations it tries to find the hwdb.bin file from:

openat(AT_FDCWD, "/etc/systemd/hwdb/hwdb.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/udev/hwdb.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/systemd/hwdb/hwdb.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/systemd/hwdb/hwdb.bin", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/udev/hwdb.bin", O_RDONLY|O_CLOEXEC) = 3

Within a container, you could put the hwdb.bin file into whichever of those locations makes the most sense to you.

1
  • If you can expand your answer, then I can accept it. I had to do my own research to find out how to get hwdb.bin into the distro.
    – Drakes
    Nov 24, 2020 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .