使用docker for mac在docker容器中暴露TTY设备 [英] Exposing a TTY device in a docker container with docker for mac

查看:784
本文介绍了使用docker for mac在docker容器中暴露TTY设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图将插入我的mac的Arduino暴露给我在

I'm trying to expose an Arduino that's plugged into my mac to a linux instance I'm running in Docker for Mac (no vm).

Arduino将自己公开为/dev/tty.usbserialXXX.我正在使用基于ubuntu的node泊坞窗映像.

The Arduino exposes itself as /dev/tty.usbserialXXX. I'm using the node docker image which is based upon ubuntu.

我正在运行的命令是

$ docker run --rm -it -v `pwd`:/app --device /dev/tty.usbmodem1421 node bash
docker: Error response from daemon: linux runtime spec devices: error gathering device information while adding custom device "/dev/tty.usbmodem1421": lstat /dev/tty.usbmodem1421: no such file or directory.

如果我尝试使用--privileged

$ docker run --rm -it -v `pwd`:/app --device /dev/tty.usbmodem1421 --privileged node bash
root@8f18fdbcf64d:/# ls /dev/tty.*
ls: cannot access /dev/tty.*: No such file or directory

什么都没有暴露!

我正在使用它来公开串行设备以在Linux中测试串行驱动程序./p>

I'm using this to expose serial devices to test serial drivers in linux.

推荐答案

这里的问题主要是您没有在Mac上运行Docker .您正在Mac上运行Linux VM,并在其中运行Docker.这意味着将Linux VM中的/dev树公开给Docker很容易,但是缺少虚拟机管理程序的某种支持,则不太容易公开Mac中的设备.

The problem here is largely that you're not running Docker on your mac. You're running a Linux VM on your Mac, inside which you're running Docker. This means that it's easy to expose the /dev tree inside the Linux VM to Docker, but less easy to expose devices from your Mac, absent some kind of support from the hypervisor.

使用基于VirtualBox构建的Mac遗留的"Docker工具箱",应该可以将USB设备分配给运行Docker的VirtualBox主机(这将使您可以将其公开给Docker容器)

Using the legacy "Docker Toolbox" for Mac, which is built around VirtualBox, it ought to be possible to assign a USB device to the VirtualBox host running Docker (which would in turn allow you to expose it to your Docker containers).

此GitHub问题讨论了这种特殊情况,并提供了有用文档的链接.

This GitHub issue talks about this particular situation and has links to helpful documentation.

我不知道新的"Docker for Mac"软件包中使用的管理程序当前是否具有这种功能.

I don't know if this sort of feature is currently available with the hypervisor used in the newer "Docker for Mac" package.

这篇关于使用docker for mac在docker容器中暴露TTY设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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