泊坞窗容器无法看到的SerialPort设备 [英] Docker container can't see a serialport device
问题描述
我想可以访问的主机的SerialPort跑码头工人的容器。
下面是我所做的:
I'm trying to run a docker container with access to a 'serialport' in the host. Here is what I did:
- 我用MAC
- 在主机上安装的驱动程序
( http://www.prolific.com.tw/美国/ ShowProduct.aspx P_ID = 229安培; PCID = 41 ) - 插入设备
- 运行
LS的/ dev /吨*
的返回/dev/tty.usbserial
- 所以它的工作原理 - 运行容器
泊坞窗运行 - 它--privileged -v / dev的是:/ dev
然后
节点:4.4.0 /斌/庆典LS的/ dev /吨*
这没有返回<$ C $容器内C> /dev/tty.usbserial 设备...
- I used MAC
- installed drivers on the host (http://www.prolific.com.tw/US/ShowProduct.aspx?p_id=229&pcid=41)
- plugged in the device
- run
ls /dev/t*
that returned/dev/tty.usbserial
- so it works - run the container
docker run -it --privileged -v /dev:/dev node:4.4.0 /bin/bash
and thenls /dev/t*
inside the container which didn't return the/dev/tty.usbserial
device...
我打了很多的参数不同的变化,但还没有找到工作的:)另外, - 设备
标志不适合我,因为该设备可能重新连接和名称可能从 /dev/tty.usbserial
I played a lot with different variations of parameters but haven't found the working one :) Also the --device
flag is not suitable for me since the device might be reconnected and the name could differ from /dev/tty.usbserial
推荐答案
您可以检查中所描述的剧本的在泊坞窗容器新的USB设备的通知(摘自的圭多Diepen - gdiepen
)可帮助
You can check if the script described in "Notification of new USB devices in docker container" (from Guido Diepen -- gdiepen
) can help.
他也经营着与容器 - 特权
参数允许它访问的设备。他登上了主机目录的/ dev /巴士/ USB
到容器内的/ dev /巴士/ USB
目录用参数 -v的/ dev /巴士/ USB:为/ dev /巴士/ USB
当启动该容器
He too runs his container with the --privileged
argument to allow it to access the devices. And he mounts the host directory /dev/bus/usb
to the /dev/bus/usb
directory within the container with the argument -v /dev/bus/usb:/dev/bus/usb
when starting said container.
该脚本同时使用 inotifywait
和的lsusb
等待设备对(联合国)插上电源,检查它是否在设备,我们感兴趣的东西。
The script uses both inotifywait
and lsusb
to wait for devices to be (un)plugged and check if it was the device we are interested in.
的 inotifywait
将继续倾听的inode 下创建/删除事件开发/巴士/ USB
目录每当的inode
对应于相关设备已刚刚创建将执行命令。
The
inotifywait
will keep on listening to inodes create/delete events under thedev/bus/usb
directory and will execute commands whenever aninode
corresponding to a relevant device has been just created.
又见,一旦检测到一个插入USB设备,如何获得总线和设备关系的的/ dev / ttyUSB
(不涉及码头工人,但仍相关)
See also, once you have detected an plugged USB device, How to get Bus and Device relationship for a /dev/ttyUSB
(not related to docker, but still relevant)
这篇关于泊坞窗容器无法看到的SerialPort设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!