Docker - 任何方式可以访问主机USB或串行设备? [英] Docker - any way to give access to host USB or serial device?
问题描述
上次我检查过, docker 没有任何方法允许容器访问主机串口或USB端口。我想知道是否有任何技巧,任何人都知道哪个允许这样做
Last time I checked, docker didn't have any means to give container access to host serial or USB port. I wonder if there is any trick that anyone here knows which allows doing that
推荐答案
有几个选项。首先,如下面的@Mark所述,docker 1.2.0版(2014/08发布)添加了 - 设备
标志,可用于访问USB设备而无需 - 特权
模式:
There are a couple of options. First and foremost, as noted by @Mark below, docker version 1.2.0 (released 2014/08) added the --device
flag that use can use to access USB devices without --privileged
mode:
docker run -t -i --device=/dev/ttyUSB0 ubuntu bash
或者,假设您的USB设备可用于驱动程序等主机在 / dev / bus / usb
中,您可以使用特权模式和卷选项。例如:
Alternatively, assuming your USB device is available with drivers working etc on the host in /dev/bus/usb
, you can mount this in the container using privileged mode and the volumes option. For example:
docker run -t -i --privileged -v /dev/bus/usb:/dev/bus/usb ubuntu bash
这篇关于Docker - 任何方式可以访问主机USB或串行设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!