Docker - 任何方式可以访问主机USB或串行设备? [英] Docker - any way to give access to host USB or serial device?

查看:1421
本文介绍了Docker - 任何方式可以访问主机USB或串行设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上次我检查过, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆