Docker-一种访问主机USB或串行设备的方法? [英] Docker - a way to give access to a host USB or serial device?
本文介绍了Docker-一种访问主机USB或串行设备的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我上次检查时, Docker没有任何方法可以使容器访问主机串行或USB端口。
推荐答案
有两种选择。您可以使用-device
标志,该标志可用于访问没有-特权
模式的USB设备:
There are a couple of options. You can use 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
,您可以使用特权模式和 volumes选项。例如:
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
请注意,顾名思义,是特权
是不安全,应为小心处理。
Note that as the name implies, --privileged
is insecure and should be handled with care.
这篇关于Docker-一种访问主机USB或串行设备的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文