udevadm does not show all attributes inside a docker container

时光怂恿深爱的人放手 提交于 2019-12-05 16:23:11

If you only care about getting information from the udev database, then you can mount the host's udev database into the docker container, e.g.,

-v /run/udev:/run/udev:ro

By doing so, you won't need to run a udev daemon inside the docker container, but still get all the ID_ attributes when doing udevadm info. This worked for me for a Debian docker container running on a Debian host.

I also suggest mounting /dev as well so your docker container will know about any changes to the device files.

According to this this blog, udev just does not play well with docker when running in containers. I thus decided that this problem needs a workaround. With udev I only get the path of the device in /sys, and get the needed information directly from that path, e. g.:

container# cat "/sys$(udevadm info -q path /dev/bus/usb/002/009)/idVendor"

I am going to mark this as solved, however it's just a workaround, not the real answer to the question.

EDIT

According to this post, these flags are needed to get udevadm display the udev events (along with attributes): --net=host -v /dev:/dev

This only works for udevadm monitor, not for udevadm info.

Add the following udev rule to populate the ID_ properties:

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb"
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!