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).
The Arduino exposes itself as /dev/tty.usbserialXXX
. I'm using the node
docker image which is based upon ubuntu.
The command I'm running is
$ 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.
If I try to use --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
Nothing is exposed!
I'm using this to expose serial devices to test serial drivers in linux.
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.
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).
This GitHub issue talks about this particular situation and has links to helpful documentation.
I don't know if this sort of feature is currently available with the hypervisor used in the newer "Docker for Mac" package.
The Arduino devise that is listed at /dev/tty.usbserialXXX
could be a symlink to the device, and not the actual path. To read the symlink path try using
docker run --rm -it -v `pwd`:/app --device=/dev/$(readlink /dev/tty.usbmodem1421) node bash
There was an issue open for this some time back. Do check if it solves your problem